我正在做一个简单的基于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)
答案 0 :(得分:1)
出于某种原因,IntelliJ项目浏览器显示“Messages.properties”文件的路径,好像它是一系列文件夹,而在窗帘后面,它只创建一个文件夹,其中包含整个路径的名称。 通过重新设置资源文件夹内的文件夹结构来解决问题(文件保持完全相同)。