java.util.MissingResourceException:找不到基本名称消息的包,区域设置 en_US

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10927032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 03:06:47  来源:igfitidea点击:

java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US

javajsfjsf-2jsf-1.2

提问by digvijay

I am new to JSF an was trying out this piece of code.. This is my faces-config.xml:

我是 JSF 的新手,正在尝试这段代码。这是我的 faces-config.xml:

<application>
        <resource-bundle>
            <base-name>messages</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>

messages is a file that stores a few properties and messages file is not placed under any directory, it is placed directly under the application. Why cant i access this file? Thank you in advance.. please do let me know if you need any additional information..

消息是一个存储一些属性的文件,消息文件不放在任何目录下,它直接放在应用程序下。为什么我不能访问这个文件?预先感谢您.. 如果您需要任何其他信息,请告诉我..

采纳答案by Daniel

looks like your file placed in some package inside your srcfolder

看起来您的文件放在src文件夹内的某个包中

<base-name>some.package.name.Messages</base-name>

also make sure the file called Messages.properties

还要确保文件名为 Messages.properties

b.t.w are you aware that Messages.propertiesfile will allow you to override your validators error messages?

顺便说一句,您是否知道该Messages.properties文件将允许您覆盖验证器错误消息?

Also, take a look at this nice tutorial JSF 2 message and messages example

另外,看看这个不错的教程JSF 2 消息和消息示例

回答by 1337

If you put it in directly into src folder it should work. Athough I would suggest to organize the message files in packages.

如果您将它直接放入 src 文件夹,它应该可以工作。虽然我建议在包中组织消息文件。