Question

I am implementing Internalization in Spring MVC. Below is my applicationcontext xml file

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="/WEB-INF/ApplicationResources"></property>
</bean>

I have kept ApplicationResources_en.properties file under /Webcontent/WEB-INF/ directory.

In JSP, I m loading messages using <fmt:message> tag. But I m getting message as below.
???addEmployee.UserName???

Can anybody help me please?

Was it helpful?

Solution

Make sure that you registered a LocaleChangeInterceptor bean to intercept the user's Locale:

<mvc:interceptors>    
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
      p:paramName="locale" />
</mvc:interceptors>

Then try to use <spring:message code="addEmployee.UserName" text="username" /> instead of tag.

Otherwise, the <spring:message> closely resemebles to <fmt:message> except that the later does not use the Spring locale resolver and you have to change the resolver to

`<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>` 

which will set a LocalizationContext for JSTL tags.

BR.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top