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

Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>