java “找不到基本名称消息的包”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7886729/
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-30 21:50:47  来源:igfitidea点击:

"Can't find bundle for base name messages" error

javajsf-2

提问by Francesco

while running my application I get the following error:

在运行我的应用程序时,我收到以下错误:

javax.el.ELException: /view/doi/common/navigation.xhtml: Can't find bundle for base name messages, locale de_CH
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:90)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

In my faces-config I specified this:

在我的 faces-config 中,我指定了这个:

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

and I have a directory src\web\resources\msg with the file messages_en.propeties.

我有一个目录 src\web\resources\msg,其中包含文件 messages_en.propeties。

What am I missing?

我错过了什么?

回答by ivantod

Based on the exception, the locale that the server is looking for is de_CHor failing that, de. If that fails too, then it will look for 'default' language, but what that is, depends on your system settings. So it may never even go to messages_en.properties. You could provide messages.propertiesinstead (without any locale indicator) to serve as a default, if that's what you want.

基于异常,服务器正在寻找的语言环境是de_CH或失败,de. 如果这也失败了,那么它会寻找“默认”语言,但那是什么,取决于您的系统设置。所以它甚至可能永远不会去messages_en.propertiesmessages.properties如果这是您想要的,您可以提供(不带任何区域设置指示符)作为默认值。

Also read here for the full explanation of how the locale resolution works: http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/

另请阅读此处以获取有关区域设置解析如何工作的完整说明:http: //java.sun.com/developer/technicalArticles/Intl/ResourceBundles/