Could not open ServletContext resource [/WEB-INF/action-servlet.xml]

严重: action: null 
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/action-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servlet.xml]  
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servlet.xml]

----------------------------------------------------------------------


在WEB-INF 下确实是没有找到action-servlet.xml , 可问题我根本没有编辑这个xml文件 更加没有引用他


----------------------------------------------------------------------
Struts.xml  文件配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="housceForm" type="com.tjsoft.struts.form.HousceForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      input="/housce.jsp"
      name="housceForm"
      path="land"
      type="com.tjsoft.struts.action.HousceAction">
      <forward name="houserCk" path="/houseCK.jsp" />
    </action>
  </action-mappings>
  <message-resources parameter="com.tjsoft.struts.ApplicationResources" />
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  <set-property property="ContextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
  </plug-in>
</struts-config>



----------------------------------------------------------------------

Web.xml   文件配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
  <context-param>
  <param-name>contextConfig</param-name>
  <param-value>/WEB-INF/aplicationContext.xml</param-value>
  </context-param>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
   <param-name>namespace</param-name>
   <param-value>admin-servlet</param-value>
</init-param>
   
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>


----------------------------------------------------------------------

在网上看到一兄弟的回帖:
检查在struts-config.xml中是否配置了结合spring使用的插件<plug-in>,以及其中的contextConfigLocation属性是否配置了正确的值。

错误提示是在WEB-INF下找不到名为action-servlet.xml的spring配置文件,该名称为struts结合spring时默认查找的文件位置和文件名,如果没有配置上面的插件或配置错误都会提示这个异常


于是检查struts-config.xml,发现 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  <set-property property=" ContextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
  </plug-in>
的头字母“C"是大写的。改成小写,重启系统。异常信息没有了。

----------------------------------------------------------------------

你可能感兴趣的:(spring,Web,xml,servlet,struts)