报错如下:ValidatorResources not found in application scope under key "org.apache.commons.validator.VALIDATOR_RESOURCES"
注:我的用的是普通的Action.Form,所有验证的在Form中。
请高手解决下
注:我的用的是普通的Action.Form,所有验证的在Form中。
请高手解决下
解决方案 »
- 文件上传完后需要进行复制解压功能,怎么直接响应,把复制解压功能放后台运行
- formbean中接收下拉列表值的问题
- struts中有没有多个Action对应用一个ActionForm,或是多个ActionForm对应用一个Action
- web应用中如何做柱状图和折线图?
- ssh 框架中json 的作用?
- hibernate中多对多产生的新表如何操作!急!在线等
- JDBC和HIBERNATE的问题
- struts的问题d
- jdbc连接mysql的问题
- web service 问题 !!求懂的人进来!!!!
- 工作了半年任在困惑的菜鸟求指点。
- document.body.innerHTML的问题,急救!!!(全部身家)
要学会看错误提示
其实就是配置没搞好
<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>
另一个是配置一下三楼的resource.
用的不是带验证的动态form,是普通的form验证方法都写在form中,所以以上配置不行
/*
* 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");
}
}
<!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>