标签:blog http io ar cti sp log on c
//第一种方法(继承SessionAware类来取得session,然后用invalidate()方法清理)
public class ExitAction extends ActionSupport implements SessionAware{
@Override
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session1 = request.getSession();
session1.invalidate();
return super.execute();
}
public void setSession(Map arg0) {
}
}
//第二种方法(用ActionContext取session,然后用clear()方法清理)
public class ExitAction extends ActionSupport{
@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{
@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();
}
}
相关链接【很重要!】http://www.iteye.com/problems/28692
http://jackzhangyunjie.iteye.com/blog/231205/
http://bbs.csdn.net/topics/340144247
标签:blog http io ar cti sp log on c
原文地址:http://www.cnblogs.com/sungyouyu/p/3873980.html