【问题标题】:Cannot find message resources under key org.apache.struts.action.MESSAGE in struts在struts中找不到key org.apache.struts.action.MESSAGE下的消息资源
【发布时间】:2011-02-14 11:26:09
【问题描述】:

我在浏览器窗口中收到以下错误:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE

我在 struts-config.xml 中使用了资源文件

并且我的资源文件存储为 WEB-INF/classes/Application.properties 文件。

【问题讨论】:

  • 我刚刚收到此错误,结果发现我的 struts 配置 xml 文件中有错误。

标签: struts struts-1


【解决方案1】:

嗯,这是一篇旧帖子,但我的回答可能会有所帮助,我想...... 我个人浪费了一些时间来制作一个在 Tomcat 7 下在 Tomcat 5.5 下开发的项目。

注意:您应该将资源文件命名为:“ApplicationResources”...

它不起作用有几个原因,但我在网上找到的最常见的答案是:放行

<message-resources parameter="ApplicationResources" null="false" />

在你的“struts-config.xml”中。

就我而言,这一行已经存在,而恰恰相反:我必须删除它并在“web.xml”文件级别替换为:

    <context-param>
        <param-name>application</param-name>
        <param-value>ApplicationResources</param-value>
    </context-param>

在“servlet”标签中。

很抱歉,我对此没有有价值的解释,但我的应用程序现在运行良好。 有人有(解释)吗?

【讨论】:

    【解决方案2】:

    这发生在我身上,因为我正在将我的项目转换为 maven,而我的 resources 目录不正确。

    我有这样的 struts-config.xml:

    <message-resources parameter="messages.appResources" null="false"/>
    

    我的 pom.xml 是这样的:

            <resource>
                <directory>src/main/resources</directory>
            </resource>
    

    但我的messages 文件夹位于我的项目根目录中。所以我把它移到:

    ${project.basedir}/src/main/resources/messages
    

    【讨论】:

      【解决方案3】:

      确保您在 struts-config.xml 的标头中使用相同版本的 DTD:

      我在使用两个不同的版本时遇到了这个错误:

      //CN" "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">

      修正后 Pb 就解决了:

      【讨论】:

        【解决方案4】:

        可能缺少 XML... 您的应用程序在哪个上下文中运行?雄猫?老板?

        尝试包含 xalan 和 xerces 依赖项。

        【讨论】:

          【解决方案5】:

          以下解决了我的问题:

          在 Struts Config 中,包括:

          (在顶部)

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE struts-config PUBLIC 
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
          "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
          

          <message-resources
              parameter="common.properties.Common" /> (or the path to your resources file)
          

          这个错误似乎是由于 struts-config.xml 中缺少消息资源的路径引起的 以及顶部的 DOCTYPE 定义。

          【讨论】:

            【解决方案6】:

            你应该把这一行放在你的 struts-config.xml 中

            key="ApplicationResources" />

            【讨论】:

              【解决方案7】:

              在我的情况下,从struts-config.xml 文件中的message-resources 元素中删除所有不必要的属性后,问题得到了修复。就像下面这样:

              <message-resources parameter="ApplicationResources"/>
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2020-03-27
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2013-05-18
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多