2012-03-05 46 views

回答

0

我用下面的代码来实现我的目标:

Authentication auth = SecurityContextHolder.context.authentication 
new SecurityContextLogoutHandler().logout(request, response, auth); 
new PersistentTokenBasedRememberMeServices().logout(request, response, auth); 
5

这是另一种方法。我从bean“logoutHandlers”获得注销处理程序,然后在每个注销中注销:

def logoutHandlers 
def logout(request,response) { 
    Authentication auth = SecurityContextHolder.context.authentication 
    if (auth) { 
     logoutHandlers.each { handler-> 
      handler.logout(request,response,auth) 
     } 
    } 

}