Pages

Wednesday, February 8, 2012

Internationalization support using Spring MVC application

To make Spring MVC application supports the internationalization, register two beans :
1.SessionLocaleResolver
If you don't register the localeResolver the default AcceptHeaderLocaleResolver will be used
to resolve locale by checking the "accept-language" header from the incomming HTTP request.
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">


Note :
If there is a repated need of locale resolution add the above code else we may
get the below exception.
java.lang.UnsupportedOperationException: Cannot change HTTP accept header - use a different locale resolution strategy

2.LocaleChangeInterceptor
Register this to support multiple languages.Property paramName is used to set the locale.

class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">









No comments:

Post a Comment