Reputation: 14727
I am aware of two ways:
RequestContextUtils.getLocale(request);
LocaleContextHolder.getLocale();
Do they always deliver the same result?
Regards and thanks.
Upvotes: 1
Views: 2778
Reputation: 64059
From the Javadoc of RequestContextUtils
:
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 ServletRequest.getLocale() method, falling back to the latter if no more specific locale has been found.
Consider using LocaleContextHolder.getLocale() which will normally be populated with the same Locale.
It seems that it will normally be populated with the same value, but not always
Upvotes: 2