org.springframework.web.servlet.i18n
Class AcceptHeaderLocaleResolver
java.lang.Object
org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
- All Implemented Interfaces:
- LocaleResolver
public class AcceptHeaderLocaleResolver
- extends Object
- implements LocaleResolver
Implementation of LocaleResolver that simply uses the primary locale
specified in the "accept-language" header of the HTTP request (that is,
the locale sent by the client browser, normally that of the client's OS).
Note: Does not support setLocale
, since the accept header
can only be changed through changing the client's locale settings.
- Since:
- 27.02.2003
- Author:
- Juergen Hoeller
- See Also:
ServletRequest.getLocale()
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AcceptHeaderLocaleResolver
public AcceptHeaderLocaleResolver()
resolveLocale
public Locale resolveLocale(HttpServletRequest request)
- Description copied from interface:
LocaleResolver
- Resolve the current locale via the given request.
Should return a default locale as fallback in any case.
- Specified by:
resolveLocale
in interface LocaleResolver
- Parameters:
request
- the request to resolve the locale for
- Returns:
- the current locale (never
null
)
setLocale
public void setLocale(HttpServletRequest request,
HttpServletResponse response,
Locale locale)
- Description copied from interface:
LocaleResolver
- Set the current locale to the given one.
- Specified by:
setLocale
in interface LocaleResolver
- Parameters:
request
- the request to be used for locale modificationresponse
- the response to be used for locale modificationlocale
- the new locale, or null
to clear the locale
Copyright © 2002-2007 The Spring Framework.