Register.jsp
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html:form action="register.do">
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>struts-config.xml
<!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>
<data-sources />
<form-beans><form-bean name="RegisterForm" type="app.RegisterForm" /></form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action path="/register"
type="app.RegisterAction"
name="RegisterForm"
scope="session"
validate="false"
input="/Register.jsp"
>
<forward name="success" path="/success.html" redirect="false" />
<forward name="failure" path="/failure.html" redirect="false" />
</action>
</action-mappings>
<controller />
<message-resources parameter="com.youcompany.struts.ApplicationResources" />
</struts-config>错误:javax.servlet.ServletException: No getter method for property: "username" of bean: "app.RegisterForm"
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html:form action="register.do">
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>struts-config.xml
<!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>
<data-sources />
<form-beans><form-bean name="RegisterForm" type="app.RegisterForm" /></form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action path="/register"
type="app.RegisterAction"
name="RegisterForm"
scope="session"
validate="false"
input="/Register.jsp"
>
<forward name="success" path="/success.html" redirect="false" />
<forward name="failure" path="/failure.html" redirect="false" />
</action>
</action-mappings>
<controller />
<message-resources parameter="com.youcompany.struts.ApplicationResources" />
</struts-config>错误:javax.servlet.ServletException: No getter method for property: "username" of bean: "app.RegisterForm"
STRUTS里应该叫 FORM吧
package app;import org.apache.struts.action.*;public class RegisterForm extends ActionForm{
protected String username = null;
protected String password1= null;
protected String password2= null;
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;
}
}
return this.username;
}
大小写问题getUserName-----getUsername