//第一種方法(繼承SessionAware類來取得session,而後用invalidate()方法清理)
public class ExitAction extends ActionSupport implements SessionAware{session
@Override
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session1 = request.getSession();
session1.invalidate();
return super.execute();
}ide
public void setSession(Map arg0) {
}.net
}
//第二種方法(用ActionContext取session,而後用clear()方法清理)
public class ExitAction extends ActionSupport{blog
@Override
public String execute() throws Exception {
ActionContext ac = ActionContext.getContext();
Map session = ac.getSession();
session.clear();
return super.execute();
}繼承
}
//第三種方法(同樣用ActionContext取session,而後取一個Session的KEY,清除該KEY的session,這種辦法能夠選擇性的清理你要清理的session)
public class ExitAction extends ActionSupport{rem
@Override
public String execute() throws Exception {
ActionContext ac = ActionContext.getContext();
Map session = ac.getSession();
session.remove("buser");
session.remove("guser");
session.remove("fuser");
return super.execute();
}
}get
相關連接【很重要!】http://www.iteye.com/problems/28692it
http://jackzhangyunjie.iteye.com/blog/231205/io
http://bbs.csdn.net/topics/340144247class