1. 程式人生 > >退出登入功能

退出登入功能

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";
	}