我正在做一個簡單的基於JSF的項目(請參閱this image檢查項目結構),但我不明白爲什麼faces-config無法到達消息。「無法找到基本名稱捆綁」在JSF messages.properties
下面是引用「Messages.properties」文件中的「faces-config.xml中」的代碼段:
<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)
將您的Messages.properties重命名爲Messages_pt_BR.properties,構建,部署並查看它是否可行。 – Bonifacio
@Bonifacio錯誤仍然存在。一模一樣。 –
@Kukeltje它位於結構中的正確位置,但我不知道如何在部署後檢查它是否保留在該位置。 –