Missing configuration resource for path /WEB-INF/struts-config.xml
在学struts,用的是myeclipse,以前都一直好好的,从昨晚就开出问题了,在启动Tomcat的时候,会报这个错误:Missing configuration resource for path /WEB-INF/struts-config.xml
我的文件明明存在,路径为web-inf下面,为什么会报找不到的错误呢?
web.xml文件的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- Standard Action Servlet Configuration (with debugging)
-->
- <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>debug</param-name>
<param-value>2</param-value>
</init-param>
- <init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
- <!-- Standard Action Servlet Mapping
-->
- <servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
比如我一个项目的struts-config.xml :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.pyj.struts.LoginActionForm"/>
</form-beans>
<action-mappings>
<action path="/login"
type="com.pyj.struts.LoginAction"
name="loginForm"
scope="request"
validate="false"
>
<forward name="success" path="/login_success.jsp"/>
<forward name="error" path="/login_error.jsp"/>
</action>
</action-mappings>
</struts-config>
[解决办法]
那是因为你把struts-config.xml配置文件放置到了WEBRoot目录下面了 ,你应该放到WEB-INF目录下面,然后再重新启动Tomat应该 不会出现刚才的那样错误了!
[解决办法]
你在多个工程里用到了同一个tomcat,造成路径紊乱,只保留当前工程对tomcat连接应用就可以解决问题了