@RequestMapping(value = "**/language", method = RequestMethod.GET)
public String saveUserLanguage(@RequestParam(value = "lang", defaultValue = "en") String lang,
HttpServletResponse response, HttpServletRequest request) throws ServletException {
JCUser jcuser = userService.getCurrentUser();
Language languageFromRequest = Language.byLocale(new Locale(lang));
if (!jcuser.isAnonymous()) {
changeLanguageWithLockHandling(jcuser, languageFromRequest);
}
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
localeResolver.setLocale(request, response, languageFromRequest.getLocale());
return "redirect:" + request.getHeader("Referer");
}