自己从页面中各个控件中搜集数据,放入Form中,以供其他页面
使用(要把该Form的作用域设置为session)
public final class HelloForm extends ActionForm {
private String userName = null;
public String getUserName() {
return (this.userName);
}
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Reset all properties to their default values.
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.userName = null;
}
}
<action path = "/HelloWorld"
type = "hello.HelloAction"
name = "HelloForm"
scope = "session"
validate = "false"
input = "/view/test/hello.jsp"
>
<forward name="SayHello" path="/view/test/hello.jsp" />
</action>
页面可以通过以下方式获得:
<bean:define id="helloForm" name="HelloForm" toScope="session"/>
helloForm:<bean:write name="helloForm" /><br>
helloForm.userName:<bean:write name="helloForm" property="userName"/>
<br>
<br>
<logic:equal name="HelloForm" scope="session" property="userName" value="xiaoming">
xiaoming is a good boy!
</logic:equal>
<br>
<br>
<logic:empty name="HelloForm" scope="session" property="userName">
userName is empty!
</logic:empty>