Most parts of Spring's architecture support internationalization, just as the Spring web MVC frame work does. Dispatcher Servlet enables you to automatically resolve messages using the client's locale.This is done with Locale Resolver objects.
When a request comes in, the Dispatcher Servlet looks for a locale resolver, and if it finds one it tries to use it to set the locale. Using the Request Context. get Locale() method, you can always retrieve the locale that was resolved by the locale resolver.
In addition to automatic locale resolution, you can also attach an interceptor to the handler mapping to change the locale under specific circumstances, for example, based on a parameter in the request.
Locale resolvers and interceptors are defined in the org. spring frame work. web. servlet.i18n package and are configured in your application context in the normal way. Here is a selection of the locale resolvers included in Spring.
Accept Header Locale Resolver
This locale resolver inspects the accept-language header in the request that was sent by the client (e.g., a web browser).Usually this header field contains the locale of the client's operating system.
This locale resolver inspects a Cookie that might exist on the client to see if a locale is specified. If so, it uses the specified locale. Using the properties of this locale resolver, you can specify the name of the cookie as well as the maximum age. Find below an example of defining a Cookie Locale Resolver.<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
Table CookieLocaleResolver properties
The Session Locale Resolver allows you to retrieve locales from the session that might be associated with the user's request.
Locale Change Interceptor
You can enable changing of locales by adding the Locale Change Interceptor to one of the handler mappings.It will detect a parameter in the request and change the locale. It calls setLocale() on the LocaleResolver that also exists in the context. The following example shows that calls to all *.view resources containing a parameter named siteLanguage will now change the locale. So, for example, a request for the following URL, http://www.sf.net/home.view?siteLanguage=nl will change the site language to Dutch.<bean id="localeChangeInterceptor"
Java-Springs Related Interview Questions
|Adv Java Interview Questions||J2EE Interview Questions|
|Core Java Interview Questions||JSP Interview Questions|
|Java-Springs Interview Questions||Java Servlets Interview Questions|
|JMS(Java Message Service) Interview Questions||Hibernate Interview Questions|
|Java applet Interview Questions||Java Interview Questions|
|Framework7 Interview Questions||Java collections framework Interview Questions|
|Java 8 Interview Questions||Java Programmer Interview Questions|
Introduction To Spring Framework
New Features And Enhancements In Spring 3.0
The Ioc Container
Validation, Data Binding, And Type Conversion
Spring Expression Language (spel)
Aspect Oriented Programming With Spring
Spring Aop Apis
Data Access With Jdbc
Object Relational Mapping (orm) Data Access
Marshalling Xml Using O/x Mappers
Web Mvc Framework
Integrating With Other Web Frameworks
Portlet Mvc Framework
Remoting And Web Services Using Spring
Enterprise Javabeans (ejb) Integration
Jms (java Message Service)
Task Execution And Scheduling
Dynamic Language Support
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.