public class AcceptHeaderLocaleResolver extends Object implements LocaleResolver
LocaleResolver
implementation 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.
ServletRequest.getLocale()
Constructor and Description |
---|
AcceptHeaderLocaleResolver() |
Modifier and Type | Method and Description |
---|---|
Locale |
resolveLocale(HttpServletRequest request)
Resolve the current locale via the given request.
|
void |
setLocale(HttpServletRequest request,
HttpServletResponse response,
Locale locale)
Set the current locale to the given one.
|
public Locale resolveLocale(HttpServletRequest request)
LocaleResolver
resolveLocale
in interface LocaleResolver
request
- the request to resolve the locale fornull
)public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale)
LocaleResolver
setLocale
in interface LocaleResolver
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