报错如下:ValidatorResources not found in application scope under key "org.apache.commons.validator.VALIDATOR_RESOURCES"
注:我的用的是普通的Action.Form,所有验证的在Form中。
请高手解决下

解决方案 »

  1.   

    其实上面都错误提示都告诉你了 
    要学会看错误提示 
    其实就是配置没搞好 
    <message-resources parameter="org.xzh.struts.ApplicationResources" /> 
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> 
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> 
    </plug-in> 
    </struts-config>
      

  2.   

    有可能是你的配置文件里有默认的路径,就是在.properties文件里,有两个解决方案,一个是把这个文件删了,
    另一个是配置一下三楼的resource.
      

  3.   


    用的不是带验证的动态form,是普通的form验证方法都写在form中,所以以上配置不行
      

  4.   

    请大家原创,不要到百度搜,那样我也会,但解决不了现贴上源码:Action类如下
    /*
     * Generated by MyEclipse Struts
     * Template path: templates/java/JavaClass.vtl
     */
    package org.demo.struts.action;import java.util.List;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.actions.DispatchAction;
    import org.demo.factory.DaoFactory;
    import org.demo.struts.form.DeptForm;
    import org.demo.vo.Dept;/** 
     * MyEclipse Struts
     * Creation date: 12-13-2010
     * 
     * XDoclet definition:
     * @struts.action path="/dept" name="deptForm" input="/form/dept.jsp" parameter="status" scope="request" validate="true"
     */
    public class DeptAction extends DispatchAction {
    /*
     * Generated Methods
     */ /** 
     * Method execute
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     */
    public ActionForward dept_list(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    DeptForm deptForm = (DeptForm) form;// TODO Auto-generated method stub
    //System.out.print("Testing-----------");
    //这里列出全部本部门的信息
    List all = null;
    try {
    all = DaoFactory.getDeptDaoInstance().queryAll();
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return mapping.getInputForward();
    }
    request.setAttribute("all",all);
    //System.out.println(all);
    //return null;
    return mapping.findForward("deptList_all");
    }
    public ActionForward insert_dept(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    DeptForm deptForm = (DeptForm) form;// TODO Auto-generated method stub
    Dept dept = new Dept();
    dept.setDname(deptForm.getDname());
    dept.setDclerk(deptForm.getDclerk());
    try {
    DaoFactory.getDeptDaoInstance().insert(dept);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return mapping.getInputForward();
    }
    return mapping.findForward("insert_deptdo");
    }
    public ActionForward delete_dept(ActionMapping mapping,ActionForm form,
    HttpServletRequest request,HttpServletResponse response){
    DeptForm deptForm = (DeptForm)form;
    System.out.println(request.getParameter("dnum"));
    try {
    DaoFactory.getDeptDaoInstance().delete(request.getParameter("dnum"));
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return mapping.getInputForward();
    }
    //return null;
    return mapping.findForward("delet_deptdo");
    }
    }
      

  5.   

    配置文件如下:<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
      <data-sources />
       <form-beans>
       <form-bean name="dept1Form" type="org.demo.struts.form.DeptForm" />
         <form-bean name="empForm" type="org.demo.struts.form.EmpForm" />
       </form-beans>
      <action-mappings >
        <action
          attribute="deptForm"
          input="/error.html"
          name="deptForm"
          parameter="status"
          path="/dept"
          scope="request"
          type="org.demo.struts.action.DeptAction">
          <set-property property="cancellable" value="true" />
          <forward name="deptList_all" path="/dept_list.jsp"></forward>
          <forward name="insert_deptdo" path="/insert_deptdo.jsp"></forward>
          <forward name="delet_deptdo" path="/delete_deptdo.jsp"></forward>
        </action>
        <action
          attribute="empForm"
          input="/error.html"
          name="empForm"
          parameter="status"
          path="/emp"
          scope="request"
          type="org.demo.struts.action.EmpAction">
          <set-property property="cancellable" value="true" />
        </action>  </action-mappings>  <message-resources parameter="org.demo.struts.ApplicationResources" />
    </struts-config>