Java 找不到资源包消息
这个问题非常相似(如果不是相同的话): 基本上,我有以下代码:Java 找不到资源包消息,java,jsf,Java,Jsf,这个问题非常相似(如果不是相同的话): 基本上,我有以下代码: <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>
<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`
在第13行处理JSP页面/LoginView.JSP时发生异常
10:
11:
12:
13:
14:
15:
16:Stacktrace:
原因:
java.util.MissingResourceException-找不到基本名称de.vogela.jsf.starter.messages和locale en的捆绑包`
我试图更改文件名,在代码中更改文件名,添加资源文件夹(但我认为它已经被正确包含),并将messages.properties文件放入所有可能的文件夹中。奇怪的是,eclipse本身显示了这个错误,它还为basename提供了空的建议框(没有默认的建议)。
如果有帮助,我的项目结构:
能否确认目录
de.vogela.jsf.starter
中是否有message.properties文件?
如果没有,请在此目录中添加message.properties,然后编译所有。检查是否仍有异常?我也面临同样的问题。 但最后,如果将messages.properties文件保存在任何包(de.vogella.jsf.starter.model)下,并包括以下内容:
de.vogela.jsf.starter.model
中的message.properties?请将message.properties移动到de.vogella.jsf.starter
或将您的jsf文件更改为
。实际上,我在所有可能的文件夹中都有该文件的副本(盲目搜索解决方案的效果),但您的替代建议有效。非常感谢。不知道为什么其他的不起作用。