1.1没有
1.2有 ValidWhen:Struts的 Validator支持 ValidWhen 规则,可实现一个数据的验证依赖于另一个数据的验证;

解决方案 »

  1.   

    是的哦,我也查了很久,requiredif好像只能验证当其他field怎么样时,他才怎么样.而不能验证本field的数据.不过我用struts 1.2时系统就无故出错了.不知道哪错了.
      

  2.   

    1.1有ActionErrors validate方法,我感觉很好用.public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
     String check= request.getParameter("check");
     String password= request.getParameter("password");
    if(!check.equals(password)){
    errors.add("error", new ActionError("alert_equal"));
    }
            return (errors);
    }在jsp中用<html:errors/>可以接受到返回错误,alert_equal是在资源文件中定义的标签.
      

  3.   

    我使用的是org.apache.struts.validator.ValidatorForm
    而不是org.apache.struts.action.ActionForm毕意public ActionErrors validate写验证规则太烦了,没有validation.xml好用.能不能有方法同时使用这两种方法?
      

  4.   

    我想其它规则用validation.xml验证,当像比较两个数据相同时的情况,就用ActionErrors validate.
      

  5.   

    struts2 的validation可以使用表达式来做。
    参看 
    http://blog.csdn.net/struts2