classes 目录下新建application.properties
内容格式如: name=somedesc
WEB-INF 目录下的struts-config.xml 中添加
<message-resources parameter="addressbook.application"/>OK 了.

解决方案 »

  1.   

    <message-resources parameter="yourClassesDirec.application"/>
      

  2.   

    javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.logon_jsp._jspService(logon_jsp.java:111)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)請問應該怎樣解決?
    我的struts.config(path:D:\Tomcat 5.0\webapps\mystruts\WEB-INF\struts.config)內容:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1
    //EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <message-resources parameter="ApplicationResources" />
    </struts-config><form-beans>
        <form-bean name="userInfoForm" type="entity.UserInfoForm" />
    </form-beans><action-mappings>
        <action input="/logon.jsp" name="userInfoForm" path="/logonAction" scope="session" 
        type="action.LogonAction" validate="false">
          <forward name="success" path="/main.jsp" />      
        </action>
    </action-mappings>
    我的ApplicationResource.properties(path:D:\Tomcat 5.0\webapps\mystruts\WEB-INF\classes\ApplicationResource.properties)內容:
    #Application Resource for the logon.jsp
    logon.jsp.title=The logon page
    logon.jsp.page.heading=Welcome World!
    logon.jsp.prompt.username=Username:
    logon.jsp.prompt.password=Password:
    logon.jsp.prompt.submit=Submit
    logon.jsp.prompt.reset=Reset#Application Resource for the main.jsp
    main.jsp.title=The main page
    main.jsp.welcome=Welcome:#Application Resource for the LogonAction.java
    error.missing.username=<li><font color="red">missing username</font></li>
    error.missing.password=<li><font color="red">missing password</font></li>
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    我的logon.jsp(path:D:\Tomcat 5.0\webapps\mystruts\logon.jsp)內容:
    <HTML>
    <HEAD>
    <TITLE><bean:message key="logon.jsp.title"/></TITLE>
    <html:base/>
    </HEAD>
    <BODY>
    <h3><bean:message key="logon.jsp.page.heading"/></h3>
    <html:errors/>
    <html:form action="/logonAction.do" focus="username">
    <TABLE border="0" width="100%">
    <TR>
    <TH align="right"><bean:message key="logon.jsp.prompt.username"/></TH>
    <TD align="left"><html:text property="username"/></TD>
    </TR>
    <TR>
    <TH align="right"><bean:message key="logon.jsp.prompt.password"/></TH>
    <TD align="left"><html:password property="password"/></TD>
    </TR>
    <TR>
    <TD align="right">
      <html:submit><bean:message key="logon.jsp.prompt.submit"/></html:submit>
    </TD>
    <TD align="left">
      <html:reset><bean:message key="logon.jsp.prompt.reset"/></html:reset>
    </TD>
    </TR>
    </TABLE>
    </html:form>
    </BODY>
    </HTML>出現的錯誤:
    javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
    救救我!
      

  3.   

    我的struts.config(path:D:\Tomcat 5.0\webapps\mystruts\WEB-INF\struts.config)內容:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1
    //EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <message-resources parameter="ApplicationResources" />
    </struts-config><form-beans>
        <form-bean name="userInfoForm" type="entity.UserInfoForm" />
    </form-beans><action-mappings>
        <action input="/logon.jsp" name="userInfoForm" path="/logonAction" scope="session" 
        type="action.LogonAction" validate="false">
          <forward name="success" path="/main.jsp" />      
        </action>
    </action-mappings>我的ApplicationResource.properties(path:D:\Tomcat 5.0\webapps\mystruts\WEB-INF\classes\ApplicationResource.properties)內容:
    #Application Resource for the logon.jsp
    logon.jsp.title=The logon page
    logon.jsp.page.heading=Welcome World!
    logon.jsp.prompt.username=Username:
    logon.jsp.prompt.password=Password:
    logon.jsp.prompt.submit=Submit
    logon.jsp.prompt.reset=Reset#Application Resource for the main.jsp
    main.jsp.title=The main page
    main.jsp.welcome=Welcome:#Application Resource for the LogonAction.java
    error.missing.username=<li><font color="red">missing username</font></li>
    error.missing.password=<li><font color="red">missing password</font></li>
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>我的logon.jsp(path:D:\Tomcat 5.0\webapps\mystruts\logon.jsp)內容:
    <HTML>
    <HEAD>
    <TITLE><bean:message key="logon.jsp.title"/></TITLE>
    <html:base/>
    </HEAD>
    <BODY>
    <h3><bean:message key="logon.jsp.page.heading"/></h3>
    <html:errors/>
    <html:form action="/logonAction.do" focus="username">
    <TABLE border="0" width="100%">
    <TR>
    <TH align="right"><bean:message key="logon.jsp.prompt.username"/></TH>
    <TD align="left"><html:text property="username"/></TD>
    </TR>
    <TR>
    <TH align="right"><bean:message key="logon.jsp.prompt.password"/></TH>
    <TD align="left"><html:password property="password"/></TD>
    </TR>
    <TR>
    <TD align="right">
      <html:submit><bean:message key="logon.jsp.prompt.submit"/></html:submit>
    </TD>
    <TD align="left">
      <html:reset><bean:message key="logon.jsp.prompt.reset"/></html:reset>
    </TD>
    </TR>
    </TABLE>
    </html:form>
    </BODY>
    </HTML>出現的錯誤:
    javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
      

  4.   

    問題已經解決!謝謝浪跡天涯兄,我的struts.config寫錯了!