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