我使用了以下配置,但用户仍然存在。它没有清除cookies。那么如何清除会话和cookies?
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/").deleteCookies("JSESSIONID")
.invalidateHttpSession(true) ;
之后我使用以下代码然后它得到错误“redirect_uri_mismatch”
@RequestMapping(value = "/logout", method = RequestMethod.POST)
public String logout(HttpServletRequest request,
HttpServletResponse response) {
HttpSession session = request.getSession(false);
if (request.isRequestedSessionIdValid() && session != null) {
session.invalidate();
}
for (Cookie cookie : request.getCookies()) {
cookie.setMaxAge(0);
cookie.setValue(null);
cookie.setPath("/");
response.addCookie(cookie);
}
return ("/new");
}
然后我使用下面的代码再次出现错误“redirect_uri_mismatch”
@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logoutPage (HttpServletRequest request, HttpServletResponse response) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null){
new SecurityContextLogoutHandler().logout(request, response, auth);
}
return "redirect:/new";
}
我分别使用了上面的代码,但没有任何反应