我正在Spring MVC中实现内部化。以下是我的applicationcontext xml文件
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/ApplicationResources"></property>
</bean>
我将ApplicationResources_en.properties文件保留在/ Webcontent / WEB-INF /目录下。
在JSP中,我使用<fmt:message>
标签加载消息。但是我收到如下消息。
??? addEmployee.UserName ???
有人可以帮我吗?
确保您注册了一个LocaleChangeInterceptor
bean来拦截用户的语言环境:
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
p:paramName="locale" />
</mvc:interceptors>
然后尝试使用<spring:message code="addEmployee.UserName" text="username" />
而不是标签。
否则,<spring:message>
紧密关联到,<fmt:message>
除非后者不使用Spring语言环境解析器,而您必须将解析器更改为
`<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>`
它将为JSTL标签设置LocalizationContext。
BR。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句