public ActionErrors validate(ActionMapping mapping,
            HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (userName.length() < 1){
System.out.println("userName errors");
errors.add("username", new ActionMessage("error.username.required"));
}
if (userId.length() < 1){
System.out.println("userId errors");
errors.add("userId", new ActionMessage("error.userId.required"));
}
return errors;}
在userForm中有如上方法,当usrId和userName什么都不输入时,能打出userId errors这个信息,但在页面什么反映也没有,我该如何在页面显示error.userId.required的错误信息哪,用的是sstruts 的validate框架 <action   path="/NewValidator"
       type="src.validate.NewValidator" 
           name="userForm" 
           input="/userinfor.jsp" 
        scope="request" >
        <forward name="userinfor" path="/userinfor.jsp" />
      </action>

解决方案 »

  1.   

    在页面增加<errors/>,加在哪儿就在哪儿显示
      

  2.   

    <%@ taglib uri="struts-html.tld" prefix="html" %>
    .......
    <html:errors/>错误提示
    Cannot find message resources under key org.apache.struts.action.MESSAGE
    WEB-INF下增加了::ApplicationResources.properties
    内容:
    errors.header=<h4>Validation Error(s)</h4><ul>
    errors.footer=</ul><hr>error.username.required=<li>Choose your username
    error.userId.required=<li>Enter your userId
    请问错在哪里?