open static fun getLocale(request: HttpServletRequest): Locale
Retrieve the current locale from the given request, using the LocaleResolver bound to the request by the DispatcherServlet (if available), falling back to the request's accept-header Locale.
This method serves as a straightforward alternative to the standard Servlet javax.servlet.http.HttpServletRequest#getLocale()
method, falling back to the latter if no more specific locale has been found.
Consider using org.springframework.context.i18n.LocaleContextHolder#getLocale()
which will normally be populated with the same Locale.
request
- current HTTP request
Return
the current locale for the given request, either from the LocaleResolver or from the plain request itself
See Also
#getLocaleResolverorg.springframework.context.i18n.LocaleContextHolder#getLocale()