localeResolver.setLocale works fine for me, try something like this:
applicationContext
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
p:basename="messages/messages" p:fallbackToSystemLocale="false" />
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
my_page.jsp
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<html>
<body>
<p><spring:message code="my.message"/></p>
</body>
</html>
\src\main\resources\messages\messages.properties
my.message=Message (default language)
\src\main\resources\messages\messages_en.properties
my.message=Message in English
\src\main\resources\messages\messages_fr.properties
my.message=Message in French
Controller
@Controller
@RequestMapping("/")
public class SampleController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String welcome(HttpServletRequest request, HttpServletResponse response) {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
localeResolver.setLocale(request, response, StringUtils.parseLocaleString("fr"));
return "my_page";
}
}
With this code I get "Message in French", if I change "fr" to "en" I get "Message in English", and without setLocale call I get "Message (default language)". Changing StringUtils.parseLocaleString("fr") to new Locale("fr") gives the same results.