3
我在Spring MVC/Security中使用ExtJS。我希望用户被重定向到登录页面时,会议已过期,我给这个在Spring安全应用程序上下文 -Spring Security&ExtJS - 在会话超时时重定向到登录页面
<session-management invalid-session-url="/login.jsp"></session-management>
但由于呼叫服务器都基于AJAX的一切,重定向不不会发生。 请建议实施此的最佳方式。 我有一个自定义UserNamePasswordAuthenticationFilter
实施了AJAX登录:
@Override
protected void successfulAuthentication(HttpServletRequest request,
HttpServletResponse response, Authentication authResult) throws IOException,
ServletException {
SavedRequestAwareAuthenticationSuccessHandler srh = new SavedRequestAwareAuthenticationSuccessHandler();
this.setAuthenticationSuccessHandler(srh);
srh.setRedirectStrategy(new RedirectStrategy() {
@Override
public void sendRedirect(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, String s) throws IOException {
// do nothing, no redirect
}
});
super.successfulAuthentication(request, response, authResult);
HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(
response);
Writer out = responseWrapper.getWriter();
out.write("{success:true}");
out.close();
}
也许与http://stackoverflow.com/questions/3930646/session-timeout-response-in-ajax有关 – Raghuram 2011-04-20 04:40:45