Spring MVC:在语言环境“en_US”的代码下找不到消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13152407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring MVC: No message found under code for locale 'en_US'
提问by nidhi
Dispatcher-servlet.xml;
Dispatcher-servlet.xml;
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="classpath:messages" /> <property name="defaultEncoding" value="UTF-8" /> </bean>
I have messages_en.properties under /resources/messages_en.properties
我在 /resources/messages_en.properties 下有 messages_en.properties
label.meetingDescription=Meeting Description
In my JSP, I am using like
在我的 JSP 中,我使用的是
<form:label path="meetingDiscription">
<spring:message code="label.meetingDescription" />
</form:label>
I am getting error;
我收到错误;
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: NoNo message found under code 'label.meetingDescription' for locale 'en_US'
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'label.meetingDescription' for locale 'en_US'
javax.servlet.ServletException:javax.servlet.jsp.JspTagException:在语言环境“en_US”的代码“label.meetingDescription”下找不到任何消息
回答by Carlos AG
You should place the "messages_en.properties" in the path /src/main/resources. Then it will be accesible by the compiled classes. Besides you should create another file called "messages.properties", which is used when the default Locale language is used (property defaulLocale of SessionLocaleResolver defined in "dispatcher-servlet.xml").
您应该将“messages_en.properties”放在路径/src/main/resources 中。然后它可以被编译的类访问。此外,您应该创建另一个名为“messages.properties”的文件,该文件在使用默认 Locale 语言时使用(“dispatcher-servlet.xml”中定义的 SessionLocaleResolver 的属性 defaulLocale)。
回答by Anna Likhachova
Just move "messages_en properties" directly to webapp folder
只需将“messages_en 属性”直接移动到 webapp 文件夹

