我正在尝试根据当前登录的用户更改语言环境。处理程序工作正常,I18n 也是,但我不明白如何将其传递给LocaleResolver
处理程序?
<http use-expressions="true">
<form-login login-page="/wellcome/" login-processing-url="/login" default-target-url="/" always-use-default-target="false"
authentication-failure-url="/wellcome/?error=1" username-parameter="email" password-parameter="password"
authentication-success-handler-ref="authenticationSuccessHandler" />
<remember-me key="butler_crm" token-validity-seconds="-1" />
<logout invalidate-session="true" logout-success-url="/" logout-url="/logout"/>
<intercept-url pattern="/wellcome/" access="permitAll"/>
<intercept-url pattern="/login" access="permitAll"/>
<intercept-url pattern="/**" access="authenticated"/>
<custom-filter ref="ajaxTimeoutRedirectFilter" after="EXCEPTION_TRANSLATION_FILTER"/>
</http>
<beans:bean id="authenticationSuccessHandler" class="com.ejl.butler.spring.AuthenticationSuccessHandler" />
处理程序:
public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
/*@Autowired
private LocaleResolver localeResolver;*/
/**
*
*/
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws ServletException, IOException {
UserDetailsExtended user = (UserDetailsExtended) authentication.getPrincipal();
/*localeResolver.setLocale(request, response, new Locale(user.getCommunicationLanguage()));*/
super.onAuthenticationSuccess(request, response, authentication);
}
}