日期:2014-05-17 浏览次数:20788 次
<validators>
<field name="msg">
<field-validator type="requiredstring">
<message>请输入信息</message>
</field-validator>
</field>
<field name="age">
<field-validator type="int">
<param name="min">13</param>
<param name="max">20</param>
<message>必须在 13至20之间</message>
</field-validator>
</field>
</validators>
public class NewValidateAction extends ActionSupport{
private String msg;
private int age;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
<action name="new_validate" class="com.wjf.action.NewValidateAction">
<result name ="input">/validate_form.jsp</result>
<result name ="success">/validate_form.jsp</result>
</action>
<body>
<s:form action="new_validate">
<s:textfield name="msg" label="姓名" />
<s:textfield name="age" label="年龄" />
<s:submit />
</s:form>
</body>
<body>
<s:form action="new_validate" method="post">
<s:textfield name="msg" label="姓名" />
<s:textfield name="age" label="年龄" />
<s:submit />
</s:form>
</body>