formbean:
public ActionErrors validate(ActionMapping mapping,
                               HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if ( (this.getUserName().trim().length() == 0)) {
      errors.add("userName", new ActionError("errors.username.required"));
    }
    if ( (this.getPassWord().length() == 0)) {
      errors.add("userpassword", new ActionError("errors.userpassword.required"));
    }
    return errors;
  }struts-config.xml
<message-resources parameter="ApplicationResources" />ApplicationResources.properties
errors.username.required = <t1>\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a</t1><br>
errors.userpassword.required = <t1>\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a</t1><br>jsp:
<html:errors/>

解决方案 »

  1.   

    多谢楼上的兄弟
    可是formbean的错误也不能在<html:errors/>输出,为什么啊?jsp的页面和程序都没有错误
      

  2.   

    你看看是不是ApplicationResources.properties文件的位置不对
    编译后这个文件是不是变成空的了。以前我就遇到过
      

  3.   

    已经解决,原来我用的struts 1.1,ActionMeassage 改为 ActionError就ok了
      

  4.   

    look
    struts-config.xml
    validate="true"
      

  5.   

    errors.add("failed", new ActionMessage("logon.jsp.failed"));//有问题
    ActionMessage是ActionError的父类,所以一个ActionMessage的对象不能用于errors.add方法,反过来到可以