最近在看Validate,刚刚动手做了个,但运行时总显示Cannot find ActionMappings or ActionFormBeans collection.我看了半天也没看出什么问题来,我用的是jBuilder2005做的,以下是全部代码:
actionForm:
package validate;
import org.apache.struts.validator.ValidatorForm;
public class CheckForm extends ValidatorForm {
private String age;
private String email;
private String passWord;
private String userName;
public String getAge() {
return age;}
public void setAge(String age) {
this.age = age;}
public void setUserName(String userName) {
this.userName = userName;}
public void setPassWord(String passWord) {
this.passWord = passWord;}
public void setEmail(String email) {
this.email = email;}
public String getEmail() {
return email;}
public String getPassWord() {
return passWord;}
public String getUserName() {
return userName;}
}
action:
package validate;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;
public class SaveAction extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,HttpServletRequest servletRequest,
HttpServletResponse servletResponse) {
CheckForm checkForm = (CheckForm) actionForm;
return actionMapping.findForward( "success ");
}
}
jsp:
<%@ page contentType= "text/html; charset=GBK " %>
<%@ taglib uri= "/WEB-INF/struts-bean.tld " prefix= "bean " %>
<%@ taglib uri= "/WEB-INF/struts-html.tld " prefix= "html " %>
<html>
<head>
<title> JSP for CheckForm form </title>
</head>
<body>
<html:form action= "SavaAction.do ">
<bean:message key= "userName "/> : <html:text property= "userName "/> <html:errors property= "userName "/> <br/>
<bean:message key= "passWord "/> : <html:password property= "passWord "/> <html:errors property= "passWord "/> <br/>
<bean:message key= "age "/> : <html:text property= "age "/> <html:errors property= "age "/> <br/>