LocaleResolver implementation that looks for a match between locales
in the Accept-Language header and a list of configured supported
locales.
See setSupportedLocales(List) for further details on how
supported and requested locales are matched.
Note
This implementation does not support setLocale since the
Accept-Language header can only be changed by changing the client's
locale settings.
jakarta.servlet.http.HttpServletRequest#getLocale()
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private Locale | |
| public List | |
| public Locale | resolveLocale(HttpServletRequest
the request to resolve the locale for request)Implements org. Resolve the current locale via the given request. |
| public void | setLocale(HttpServletRequest
the request to be used for locale modification request, HttpServletResponse the response to be used for locale modification response, Locale the new locale, or locale)null to clear the localeImplements org. Set the current locale to the given one. |
| public void | setSupportedLocales(List<Locale>
the supported locales locales)Configure the list of supported locales to compare and match against
|
| supportedLocales | back to summary |
|---|---|
| private final List<Locale> supportedLocales | |
| AcceptHeaderLocaleResolver | back to summary |
|---|---|
| public AcceptHeaderLocaleResolver() | |
| findSupportedLocale | back to summary |
|---|---|
private Locale findSupportedLocale(HttpServletRequest request, List<Locale> supportedLocales)
| |
| getSupportedLocales | back to summary |
|---|---|
| public List Get the configured list of supported locales.
| |
| resolveLocale | back to summary |
|---|---|
| public Locale resolveLocale(HttpServletRequest request) Implements org. Doc from org. Resolve the current locale via the given request. Can return a default locale as fallback in any case.
| |
| setLocale | back to summary |
|---|---|
| public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) Implements org. Doc from org. Set the current locale to the given one.
| |
| setSupportedLocales | back to summary |
|---|---|
| public void setSupportedLocales(List<Locale> locales) Configure the list of supported locales to compare and match against
In order for a supported locale to be considered a match, it must match on both country and language. If you want to support a language-only match as a fallback, you must configure the language explicitly as a supported locale. For example, if the supported locales are If there is no match, then the | |