Struts数据校验方式:
ActionForm
Action
commons-validator.jar
1.ActionForm
-- 重写ActionForm.validate ,错误封装在ActionError
LoginForm extends ActionForm implements Serializable{
public ActionErrors validate(ActionMapping mapping,HttpServletRequest req){
ActionErrors ae --- 不推荐使用
ae.add("id",new ActionError("",""))
}
}
<bean:message key="button.reset"/>
<html:errors />
2.Action
request.setAttribute("errors","");
request.findForward("");
3.commons-validator.jar
1.LoginForm extends ValidatorForm
2.validator-rules.xml , validatation.xml -> WEB-INF
validatation.xml 项目校验文件
<form-validation>
<formset>
<form name="loginForm">
<field property="" depends="">
,,,,p186