protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// 步骤1:通过session获取登录的账号
HttpSession session = request.getSession();
Student student = (Student) session.getAttribute("student");
// 步骤2:销毁session
session.invalidate();
// 步骤3:从在线列表中移除当前登录账号
@SuppressWarnings("unchecked")
List<Integer> sidOnLineList = (List<Integer>) this.getServletContext().getAttribute("sidOnLineList");
sidOnLineList.remove(student.getSid()); // 移除
this.getServletContext().setAttribute("sidOnLineList",sidOnLineList); // 刷新在线列表
// 步骤4:页面跳转
response.sendRedirect("jsp/login.jsp");
}
}。
BIG阳
慕的地8271018
千万里不及你
沧海一幻觉
相关分类