简体   繁体   中英

Cant find resource bundle messages

This question is very similar (if not the same as):

"Can't find bundle for base name messages" error

ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages

Basically, i have this code:

<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>

And when I try to run, I get

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`

I tried to change file name, change file name in code, adding resource folder (but I think it was already properly included), and putting messages.properties file in all possible folders. Curiously, eclipse itself shows this error, it also has empty suggestion boxes for basename (no default proposals). In case it helps, my project structure: http://imgur.com/3eAxWo3

Can you confirm if you have message.properties file in the directory de.vogella.jsf.starter ? If not please add the message.properties in this directory and then compile all. Check if you still get the exception?

I too faced the same issue. But finally, if you keep the messages.properties file under any package(de.vogella.jsf.starter.model) and include this as follows: < f:loadBundle basename="de.vogella.jsf.starter.model.messages" var="msg" /> It is Working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM