Пытаясь выйти из системы, иметь контроллер и. jsp:
@Controller
public class LogoutController {
@RequestMapping(value = {"/logout"}, method = RequestMethod.GET)
public String logoutDo(HttpServletRequest request,HttpServletResponse response){
HttpSession session= request.getSession(false);
SecurityContextHolder.clearContext();
session= request.getSession(false);
if(session != null) {
session.invalidate();
}
for(Cookie cookie : request.getCookies()) {
cookie.setMaxAge(0);
}
return "redirect:/";
}
}
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<html>
<head>
<title>Play the game!</title>
<link type="text/css"
rel="stylesheet"
href="/static/css/index.css">
</head>
<body>
<security:authorize access="isAuthenticated()">
authenticated as <security:authentication property="principal.username" />
</security:authorize>
<a href="/logout">Logout</a>
...
Когда я нажимаю Logout
, он перенаправляет обратно на страницу /
, но principal.username
(пользователь) по-прежнему отображается. Пожалуйста, помогите ....