js代码:
$(".logout").click(function() {
if (confirm('系统提示,您确定要退出本次登录吗?')) {
location.href = ctx + '/logout';
}
});
jsp代码:
<a href="#" class="logout">安全退出</a>
java代码:
@RequestMapping(value = "/logout")
public String logout(HttpSession httpSession) {
Student student = (Student) httpSession.getAttribute("currentUser");
if(null != student) {
httpSession.removeAttribute("currentUser");
}
return "redirect:/index";
}