2. Spring Configuration

This configures the web application for internationalized messages that can then be displayed in a JSP page using the JSTL message format tag. The basenames property of ResourceBundleMessageSource is set to 'messages' which will then look for the default message resource of messages.properties. Based on different locales, other property files can be defined like messages_es.properties for Spanish.

The LocaleChangeInterceptor is configured to look for the parameter name 'locale' to indicate a change of the user's locale. For example, adding 'locale=es' to a URL would change the locale to Spanish. The SessionLocaleResolver keeps the user's currently configured locale in session scope.

Excerpt from /WEB-INF/simple-form-servlet.xml
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
<!-- Declare the Interceptor -->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="locale"/>
<!-- Declare the Resolver -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>