0
@Autowired
private SessionLocaleResolver localeResolver;
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
// clean previous failed access
authorizationServiceConfig.cleanUserFailedAccess();
// set the session locale
localeResolver.setLocale(request, response, authorizationServiceConfig.getUserLocale());
//redirect login..
handle(request, response, authentication);
}
我需要獲取我之前在身份驗證服務中設置的SessionLocaleResolver語言環境值。但我沒有在這裏請求:(如何獲取當前會話區域設置?
public String getMessage(String key) {
String answer;
if (key == null) {
return "";
}
try {
answer = getMessageSourceAccessor().getMessage(key, "here i need the Session locale");
} catch (Exception e) {
answer = key;
}
return answer;
}
你怎麼能假設Spring WebFlow的用法? – dimitrisli 2014-10-29 19:52:58
'RequestContextHolder'由'DispatcherServlet'自動啓用。如果不使用DispatcherServlet,那麼在ServletContext中註冊一個RequestContextListener就足夠了。它沒有依賴Spring WebFlow – 2014-10-29 21:40:35
aaah你是對的。我知道org.springframework.webflow.execution.RequestContextHolder ..顯然有一個org.springframework.web.context.request.RequestContextHolder – dimitrisli 2014-10-29 21:45:09