這個問題是非常相似的(如果不一樣):無法找到資源包的消息
"Can't find bundle for base name messages" error
ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages
基本上,我有這樣的代碼:
<body>
<f:view>
<f:loadBundle basename="de.vogella.jsf.starter.messages" var="msg" />
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{msg.user}"></h:outputLabel>
<h:inputText value="#{user.name}">
<f:validator
validatorId="de.vogella.jsf.starter.validator.LoginValidator" />
</h:inputText>
<h:outputLabel value="#{msg.password}"></h:outputLabel>
<h:inputSecret value="#{user.password}">
</h:inputSecret>
</h:panelGrid>
<h:commandButton action="#{user.login}" value="#{msg.login}"></h:commandButton>
<h:messages layout="table"></h:messages>
</h:form>
</f:view>
而且當我嘗試運行時,我得到
An exception occurred processing JSP page /LoginView.jsp at line 13
10: </head>
11: <body>
12: <f:view>
13: <f:loadBundle basename="de.vogella.jsf.starter.messages" var="msg" />
14: <h:form>
15: <h:panelGrid columns="2">
16: <h:outputLabel value="#{msg.user}"></h:outputLabel> Stacktrace:
Caused by:
java.util.MissingResourceException - Can't find bundle for base name de.vogella.jsf.starter.messages, locale en`
我試圖更改文件名,更改代碼中的文件名,添加資源文件夾(但我認爲它已經正確包含),並將messages.properties文件放入所有可能的文件夾中。奇怪的是,eclipse本身顯示這個錯誤,它也有基本名稱的空建議框(沒有默認提議)。 如果有幫助,我的項目結構: http://imgur.com/3eAxWo3
正如你可以看到我鏈接到的圖像,是的,我有。事情是de.vogella.jsf.starter是我的項目名稱。 – Xyzk
@Xyzk,在圖片中我可以看到包de.vogella.jsf.starter.model中的message.properties?請將message.properties移至'de.vogella.jsf.starter'或將您的jsf文件更改爲 。 –
thiyaga
其實我在所有可能的文件夾中都有該文件的副本(盲目尋找解決方案的效果),但您的替代建議起作用。謝謝。不知道爲什麼其他人沒有工作。 – Xyzk