struts中找不到键org.apache.struts.action.MESSAGE下的消息资源

发布于 2024-10-17 02:18:53 字数 307 浏览 7 评论 0原文

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

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 文件。

I am getting the following error in the browser window :

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

I have included the resource file in the struts-config.xml using

And my resource file is stored as WEB-INF/classes/Application.properties file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

风吹雨成花 2024-10-24 02:18:53

嗯,这是一篇旧帖子,但我想我的回答可以有所帮助......
我个人浪费了一些时间来制作一个在 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”标记中的 : 。

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

Well this is an old post, but my answer can help, I guess...
I personally wasted some time to make work a poject that had been developped under Tomcat 5.5 under Tomcat 7.

Note : You should name your ressource file : "ApplicationResources"...

There is several reasons why it wouldn't work, but the most common answer I found on the net was : put the line

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

in your "struts-config.xml".

In my case, this line was already present, and this was the contrary : I had to remove it and replace at the "web.xml" file level by :

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

in the "servlet" tag.

I'm sorry that I don't have a valuable explanation for this, but my application behaves just fine now.
Does anyone has (an explanation) ?

花之痕靓丽 2024-10-24 02:18:53

这发生在我身上,因为我正在将项目转换为 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

This happened to me because I was converting my project to maven and my resources directory was not correct.

I had struts-config.xml like this:

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

My pom.xml was like this:

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

But my messages folder was in my project root. So I moved it to:

${project.basedir}/src/main/resources/messages
差↓一点笑了 2024-10-24 02:18:53

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

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

//EN"
“http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd”>

修正后,Pb 就解决了:

Make sur that you are using the same version of the DTD in the header of struts-config.xml:

I had this error when using two differents versions:

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

and the Pb was solved once the correction made:

ˉ厌 2024-10-24 02:18:53

XML 可能丢失...
您的应用程序在什么上下文中运行?雄猫?杰老板?

尝试包含 xalan 和 xerces 依赖项。

An XML might be missing...
In which context is your application running ? Tomcat ? JBoss ?

Try including xalan and xerces dependencies.

喜你已久 2024-10-24 02:18:53

以下解决了我的问题:

在 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 定义相同。

The following solved my problem:

In Struts Config, include:

(At the top)

<?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)

This error seems to be caused by a lack of a path to message-resource in struts-config.xml
and the DOCTYPE definition at the top of the same.

っ左 2024-10-24 02:18:53

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

< message-resources 参数 =“ApplicationResources” null =“false” key =“ApplicationResources” /> />

you should put this line in your struts-config.xml

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

陌伤ぢ 2024-10-24 02:18:53

就我而言,从 struts-config.xml 文件中的 message-resources 元素删除所有不必要的属性后,问题得到解决。就像下面这样:

<message-resources parameter="ApplicationResources"/>

In my case problem was fixed after delete all unnecessary attributes from message-resources element in struts-config.xml file. Just like following:

<message-resources parameter="ApplicationResources"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文