简体   繁体   English

无法找到资源包消息

[英]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 找不到MessageSource的ResourceBundle [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. 我试图更改文件名,更改代码中的文件名,添加资源文件夹(但我认为它已经正确包含了),并将messages.properties文件放置在所有可能的文件夹中。 Curiously, eclipse itself shows this error, it also has empty suggestion boxes for basename (no default proposals). 奇怪的是,eclipse本身显示了此错误,它的基名也有空的建议框(没有默认建议)。 In case it helps, my project structure: http://imgur.com/3eAxWo3 如果有帮助,我的项目结构为: http : //imgur.com/3eAxWo3

Can you confirm if you have message.properties file in the directory de.vogella.jsf.starter ? 您可以确认de.vogella.jsf.starter目录中是否具有message.properties文件? If not please add the message.properties in this directory and then compile all. 如果没有,请在此目录中添加message.properties,然后全部编译。 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. 但是最后,如果将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