使用Ajax和成功处理程序登录Spring Security

时间:2014-01-08 17:22:37

标签: spring java-ee spring-security

我正在努力让用户使用Ajax并在Spring安全的帮助下登录系统,截至目前,一切正常,并且正如预期的那样。 在成功进行身份验证时,我正在调用SuccessHandler进行一些后验证工作。

我需要将一些信息(OK状态或类似信息)传递回我的JSP页面中的调用方法,以便我可以在JSP页面中执行其他工作。 一种选择是在onAuthenticationSuccess方法

中添加以下代码
@Override
public void onAuthenticationSuccess(final HttpServletRequest request,final
HttpServletResponse response, final Authentication authentication) throws 
IOException, ServletException {

 // work done
try{
   response.getWriter().print("SUCCESS");//return "SUCCESS" string
   response.getWriter().flush();
}
catch(IOException e){
} 

} 虽然这样做会有效,但是有没有其他方法或替代方法可以很好地完成它,或者这种方法是否足够好?

0 个答案:

没有答案
相关问题