t;
</td>
</tr>
<tr>
<th align="right">
<bean:message key="prompt.password" bundle="alternate"/>:
</th>
<td align="left">
<html:password property="password" size="16" maxlength="18" redisplay="false"/>
</td>
</tr>
<tr>
<td align="right">
<html:submit value="Submit"/>
</td>
<td align="left">
<html:reset/>
</td>
</tr>
</table>
</html:form>
// Validator插件,用于form验证
<html:javascript formName="logonForm" dynamicJavascript="true" staticJavascript="false"/>
<script language="Javascript1.1" src="staticJavascript.jsp"></script>
</body>
</html:html>
Struts开发指南之工作流程(3)
时间:2010-12-15
struts-config.xml配置
<form-beans>
<!-- Logon form bean -->
<form-bean name="logonForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
<!-- Subscription form bean -->
<form-bean name="subscriptionForm"type="org.apache.struts.webapp.example.SubscriptionForm"/>
</form-beans>
<action-mappings>
<!-- Edit mail subscription -->
<action path="/editSubscription"
type="org.apache.struts.webapp.example.EditSubscriptionAction"
attribute="subscriptionForm"
scope="request"
validate="false">
<forward name="failure" path="/mainMenu.jsp"/>
<forward name="success" path="/subscription.jsp"/>
</action>
...
subscriptionForm 是一个标准的ActionForm,其中reset方法用于清除form的值,validate方法用于验证
public final class SubscriptionForm extends ActionForm {
// The maintenance action we are performing (Create or Edit).
private String action = "Create";
// Should we auto-connect at startup time?
private boolean autoConnect = false;
// The host name.
private String host = null;
private String password = null;
private String type = null;
private String username = null;
public String getAction() { return (this.action); }
public void setAction(String action) { this.action = action; }
public boolean getAutoConnect() { return (this.autoConnect); }
public void setAutoConnect(boolean autoConnect) { this.autoConnect = autoConnect; }
public String getHost() { return (this.host); }
public void setHost(String host) { this.host = host; }
public String getPassword() { return (this.password); }
public void setPassword(String password) { this.password = pass
|