jsp
<html:errors property="abc" bundle="my" />
web.xml
<message-resources key="my" parameter="com.tomuno.shop" />

解决方案 »

  1.   

    Attribute property invalid for tag errors
     
    <html:errors name="abc"/> 
    这里的name 只能是资源文件里的一个key值的引用,
    而不能是别的
      

  2.   

    -- test.jsp --
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ page contentType="text/html; charset=UTF-8" %>
    <html:html>
    <head>
    <title>
    test
    </title>
    </head>
    <body bgcolor="#ffffff">
    <h1>
    test.jsp
    </h1>
    <html:form action="/test.do" method="post">
    <html:text property="name" /> <html:errors property="name"/>
    <br>
    <html:submit value="Submit" property="Submit"/>
    </html:form>
    </body>
    </html:html>-- struts-config.xml 中一部分 --
    <struts-config>
      <form-beans>
        <form-bean name="testForm" type="web1.TestForm" />
      </form-beans>
      <action-mappings>
        <action input="/test.jsp" name="testForm" path="/test" scope="request" type="web1.TestAction">
          <forward name="test" path="/test.jsp" />
        </action>
      </action-mappings>
      <message-resources parameter="ApplicationResources" />
    </struts-config>
    -- TestForm.java -- 
    package web1;import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionMapping;
    import javax.servlet.http.HttpServletRequest;public class TestForm extends ActionForm {
        private String name;
        public String getName() {
            return name;
        }    public void setName(String name) {
            this.name = name;
        }    public ActionErrors validate(ActionMapping actionMapping,
                                     HttpServletRequest httpServletRequest) {
            ActionErrors errors = new ActionErrors();
            if (name == null || name.trim().length() == 0)
                errors.add("name", new ActionError("test.jsp.name.error"));
            return errors;
        }    public void reset(ActionMapping actionMapping,
                          HttpServletRequest servletRequest) {
        }
    }
    -- TestAction.java --
    package web1;import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForm;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.Action;public class TestAction extends Action {
        public ActionForward execute(ActionMapping mapping, ActionForm form,
                                     HttpServletRequest request,
                                     HttpServletResponse response) {
            return mapping.findForward("test");
        }
    }
    -- ApplicationResuorces.properties 中的全部内容 --
    test.jsp.name.error=name must is not null!
    以上代码经测试没有问题。