簡體   English   中英

無法找到資源包消息

[英]Cant find resource bundle messages

這個問題非常相似(如果不同):

“找不到基本名稱消息包”錯誤

找不到MessageSource的ResourceBundle [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目錄中是否具有message.properties文件? 如果沒有,請在此目錄中添加message.properties,然后全部編譯。 檢查是否仍然有異常?

我也面臨同樣的問題。 但是最后,如果將messages.properties文件保留在任何包(de.vogella.jsf.starter.model)下,並包括以下內容:<f:loadBundle basename =“ de.vogella.jsf.starter.model.messages” var =“ msg” />正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM