Hi there
I've a little question for you : I'm writing an i18n application with the language chooser in my spring security form. This form is processed by a custom filter.
I wish to set the locale at that time, but the two implementations I tried are useless, I explain under here
Case 1 : LocaleContextHolder
This just impacts nothing. No error is raised, but the locale set is not used.Code:Locale locale = StringUtils.parseLocaleString(lang.toLowerCase()); LocaleContextHolder.setLocale(locale);
Case 2 : LocaleResolver
This raise a NullPointerException when trying to use the localeResolver, because it's null.Code:Locale locale = StringUtils.parseLocaleString(lang.toLowerCase()); LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); localeResolver.setLocale(request, response, locale);
So, as a fix, in my filter, I put the locale in the session, and in my Spring Controller that is called just next the authentication, I read the locale, use the LocaleResolver and remove the locale from the session. This is a bit tricky, but this is working ...
Is there any easier way to set the Spring Locale in a Spring Security Filter (AbstractAuthenticationProcessingFilter) ?



