Cannot find ActionMappings or ActionFormBeans collection问题
快疯了,怎么老是出这个问题啊?
高手指点一下吧
下面是代码和错误提示
<?xml version= "1.0 " encoding= "ISO-8859-1 " ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN "
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd ">
<struts-config>
<form-beans>
<form-bean name= "userForm " type= "user.UserForm "/>
<form-property name= "userid " type= "java.lang.String " />
<form-property name= "pwd " type= "java.lang.String " />
</form-beans>
<action-mappings>
<action path= "/LogonAction "
type= "user.LogonAction "
name= "userForm "
scope= "request "
validate= "true "
input= "../logon.jsp ">
<forward name= "success " path= "../index.jsp "/>
<forward name= "fail " path= "../logon.jsp "/>
</action>
</action-mappings>
<message-resources parameter= "user.MessageResources "/>
</struts-config>
web.xml
<?xml version= "1.0 " ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN " "http://java.sun.com/dtd/web-app_2_3.dtd ">
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<web-app>
<!-- Remove the comments below to define a servlet. -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- <servlet> -->
<!-- <servlet-name> MyServlet </servlet-name> -->
<!-- <servlet-class> examples.MyServlet </servlet-class> -->
<!-- <init-param> -->
<!-- <param-name> myparam </param-name> -->
<!-- <param-value> 12345 </param-value> -->
<!-- </init-param> -->
<!-- </servlet> -->
<!-- -->
<!-- -->
<!-- <servlet-mapping> -->
<!-- <servlet-name> MyServlet </servlet-name> -->
<!-- <url-pattern> /mine/* </url-pattern> -->
<!-- </servlet-mapping> -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Remove the comments below to define a servlet. -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<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> 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>
<taglib>
<taglib-uri> /tags/struts-bean </taglib-uri>
<taglib-location> /Web-INF/tlds/struts-bean.tld </taglib-location>
</taglib>
<taglib>
<taglib-uri> /tags/struts-html </taglib-uri>
<taglib-location> /Web-INF/tlds/struts-html.tld </taglib-location>
</taglib>
<taglib>
<taglib-uri> /tags/struts-logic </taglib-uri>
<taglib-location> /Web-INF/tlds/struts-logic.tld </taglib-location>
</taglib>
<taglib>
<taglib-uri> /tags/struts-nested </taglib-uri>
<taglib-location> /Web-INF/tlds/struts-nested.tld </taglib-location>
</taglib>
<taglib>
<taglib-uri> /tags/struts-titles </taglib-uri>
<taglib-location> /Web-INF/tlds/struts-titles.tld </taglib-location>
</taglib>
<error-page>
<error-code> 404 </error-code>
<location> /error.jsp </location>
</error-page>
</web-app>
logon.jsp
<%@ page contentType= "text/html;charset=GBK "%>
<%@ taglib uri= "/tags/struts-html " prefix= "html "%>
<html>
<head>
<title> 登录 </title>
<meta http-equiv=Content-Type context= "text/html;charset=GBK ">
</head>
<body>
<font color= "red "> <html:errors /> </font>
<html:form action= "/LogonAction " focus= "userid ">
<table width= "100% ">
<tr>
<td>
用户名: <html:text property= "userid " maxlength= "10 " />
<font color= "red "> <html:errors property= "userid " /> </font>
</td>
</tr>
<tr>
<td>
密 码: <html:text property= "pwd " maxlength= "20 " />
</td>
</tr>
<tr>
<td> <html:submit> 登录 </html:submit> </td>
</tr>
</table>
</html:form>
</body>
</html>
[解决办法]
web.xml
/Web-INF/...
==>
/WEB-INF/...
[解决办法]
原因有很多种
1。Web.xml未初始化问题
少了一个 <load-on-startup> 0 </load-on-startup>
这样开始是没有加载这个类,就没有初始化struts-config.xml,所以找不到
actionmappings or actionformbeans collection。
2。struts-config.xml问题
3。jar包不全或版本不对
也有可能导致这个问题,从stuts例子里面拷过来就好了。struts1.1自带共10个jar包。
4。编译问题
有可能Action和Formbean没有编译,也会有这个问题,检查一下有没有对应的class文件就好。class路径不对可能也会导致这个问题。
5。版本问题
用的servlet容器和struts版本不对或这两个版本协调有问题。
在以上几条都不能解决问题的情况下,可能就是版本的问题了,换个高版本试试吧
我认为LZ问题可能是版本问题
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN "
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd ">
换成
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN " "http://struts.apache.org/dtds/struts-config_1_2.dtd ">
or把WEB.xl
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN " "http://java.sun.com/dtd/web-app_2_3.dtd ">
改为
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN "
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd ">
[解决办法]
将jsp页面中的 <html:form action= "/LogonAction " focus= "userid ">
改为 <html:form action= "LogonAction.do " focus= "userid ">
或 <html:form action= " <%=request.getContextPath()%> /LogonAction.do " focus= "userid ">
可以一试,我也说不清楚
[解决办法]
<form-beans>
<form-bean name= "userForm " type= "user.UserForm "/>
<form-property name= "userid " type= "java.lang.String " />
<form-property name= "pwd " type= "java.lang.String " />
</form-beans>
to :
<form-beans>
<form-bean name= "userForm " type= "user.UserForm ">
<form-property name= "userid " type= "java.lang.String " />
<form-property name= "pwd " type= "java.lang.String " />
<form-bean />
</form-beans>
[解决办法]
啊,错了,是:
<form-beans>
<form-bean name= "userForm " type= "user.UserForm ">
<form-property name= "userid " type= "java.lang.String " />
<form-property name= "pwd " type= "java.lang.String " />
</form-bean>
</form-beans>