斑竹请帮我看看,Exception:Cannot find ActionMappings or ActionFormBeans

03-12-15 litsnake1
我用的服务器是resin2.0
我是照着一些资料做了简单的例子,但是运行出错,希望各位帮忙看看是什么问题,谢谢!
这个测试例子中有这几个文件:
webapp/register/WEB-INF/classes/app/RegisterAction.java
webapp/register/WEB-INF/classes/app/RegisterForm.java
webapp/register/register.jsp
webapp/register/failure.html
webapp/register/success.html

配置文件web.xml:
<?xml version="1.0"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>
<!-- Action Servlet Configuration -->
<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>

<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>rigister.jsp</welcome-file>
</welcome-file-list>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>

配置文件struts-config.xml:
<?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="registerForm"
type="app.RegisterForm">
</form-bean>
</form-beans>
<action-mappings>
<action path="/register"
type="app.RegisterAction"
name="registerForm"
scope="request">
<forward name="success" path="/success.html"/>
<forward name="failure" path="/failure.html"/>
</action>
</action-mappings>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>


register.jsp文件内容:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="WEB-INF/struts-logic.tld" prefix="logic" %>

<html:html locale="true">
<body>
<html:form action="/register" >
UserName:<html:text property="username"/><br>
enter password:<html:password property="password1"/><br>
re-enter password:<html:password property="password2"/><br>
<html:submit value="Register"/>
</html:form>
</body>

</html:html>

RegisterForm 文件内容:
package app;

import org.apache.struts.action.*;

public class RegisterForm extends ActionForm
{
protected String username;
protected String password1;
protected String password2;

public String getUsername()
{
return this.username;
}

public String getPassword1()
{
return this.password1;
}

public String getPassword2()
{
return this.password2;
}

public void setUsername(String username)
{
this.username = username;
}

public void setPassword1(String password1)
{
this.password1 = password1;
}

public void setPassword2(String password2)
{
this.password2 = password2;
}
}



RegisterAction 文件内容:
package app;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;

public class RegisterAction extends Action
{
public ActionForward perform(ActionMapping mapping,ActionForm form,
HttpServletRequest req,
HttpServletResponse res)
{
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password1 = rf.getPassword1();
String password2 = rf.getPassword2();

if (password1.equals(password2))
{
try
{
//UserDirectory.getInstance().setUser(username,password1);
return mapping.findForward("success");
}
catch(Exception e)
{
return mapping.findForward("failure");
}

}

return mapping.findForward("failure");
}


}

启动resin后,在ie中输入:http://localhost:80/register/register.jsp
出错了,错误如下:

javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans
collection
at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
at _register._register__jsp._jspService(/register/register.jsp:9)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:181)
at com.caucho.server.http.Invocation.service(Invocation.java:291)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:217)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:159)
at com.caucho.server.TcpConnection.run(TcpConnection.java:136)
at java.lang.Thread.run(Thread.java:536)


请这是什么原因引起,怎么解决这个问题,谢谢,

jia2612
2003-12-21 13:13
你的Struts.jar包有没有放好呀

猜你喜欢