Problem:

  • After configuring messageSource with ResourceBundleMessageSource, messages output by webApplicationContext.getMessage are in wrong language version. But this issue doesn’t appear in spring message tag.

Solution:

Replace ResourceBundleMessageSource with ReloadableResourceBundleMessageSource, add property fallbackToSystemLocale and set to false.

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="fallbackToSystemLocale" value="false"/>
    <property name="basenames">
        <list>
            <value>classpath:messages</value>
        </list>
    </property>
</bean>

Refer to: http://day-to-day-stuff.blogspot.com/2008/07/spring-message-resource-weirdness.html