"can't find bundle for base name" 在 JSF 上 messages.properties
"can't find bundle for base name" on JSF messages.properties
我正在做一个简单的基于 JSF 的项目(请参阅 this image 查看项目结构)但我不明白为什么 faces-config 无法访问消息。
这是 "faces-config.xml" 上引用 "Messages.properties" 文件的一段代码:
<application>
<message-bundle>br.com.teste.primeiraaplicacaojsf.web.i18n.Messages</message-bundle>
<locale-config>
<default-locale>pt_BR</default-locale>
</locale-config>
</application>
这是在浏览器上生成的错误消息:
HTTP Status 500 - Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
type Exception report
message Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
java.util.MissingResourceException: Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
java.util.ResourceBundle.getBundle(ResourceBundle.java:1082)
javax.faces.component.MessageFactory.getMessage(MessageFactory.java:161)
javax.faces.component.MessageFactory.getMessage(MessageFactory.java:251)
javax.faces.component.UIInput.validateValue(UIInput.java:1149)
javax.faces.component.UIInput.validate(UIInput.java:982)
javax.faces.component.UIInput.executeValidate(UIInput.java:1248)
javax.faces.component.UIInput.processValidators(UIInput.java:712)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
javax.faces.component.UIForm.processValidators(UIForm.java:253)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
出于某种原因,IntelliJ 项目资源管理器显示 "Messages.properties" 文件的路径,就好像它是一系列文件夹一样,而在幕后它只创建一个文件夹,整个路径作为它的名称。
通过重新制作资源文件夹中的文件夹结构解决了问题(文件保持完全相同)。
我正在做一个简单的基于 JSF 的项目(请参阅 this image 查看项目结构)但我不明白为什么 faces-config 无法访问消息。
这是 "faces-config.xml" 上引用 "Messages.properties" 文件的一段代码:
<application>
<message-bundle>br.com.teste.primeiraaplicacaojsf.web.i18n.Messages</message-bundle>
<locale-config>
<default-locale>pt_BR</default-locale>
</locale-config>
</application>
这是在浏览器上生成的错误消息:
HTTP Status 500 - Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
type Exception report
message Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
java.util.MissingResourceException: Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
java.util.ResourceBundle.getBundle(ResourceBundle.java:1082)
javax.faces.component.MessageFactory.getMessage(MessageFactory.java:161)
javax.faces.component.MessageFactory.getMessage(MessageFactory.java:251)
javax.faces.component.UIInput.validateValue(UIInput.java:1149)
javax.faces.component.UIInput.validate(UIInput.java:982)
javax.faces.component.UIInput.executeValidate(UIInput.java:1248)
javax.faces.component.UIInput.processValidators(UIInput.java:712)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
javax.faces.component.UIForm.processValidators(UIForm.java:253)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
出于某种原因,IntelliJ 项目资源管理器显示 "Messages.properties" 文件的路径,就好像它是一系列文件夹一样,而在幕后它只创建一个文件夹,整个路径作为它的名称。 通过重新制作资源文件夹中的文件夹结构解决了问题(文件保持完全相同)。