第一种方法(继承SessionAware类来取得session,然后用invalidate()方法清理)
@Override
public String execute() throws Exception {
HttpServletRequest request =ServletActionContext.getRequest();
HttpSession session = request.getSession();
session.invalidate();
return super.execute();
}
//第二种方法(用ActionContext取session,然后用clear()方法清理)
@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)
@Override
public String execute() throws Exception {
ActionContext ac = ActionContext.getContext();
Map session = ac.getSession();
session.remove("info");
return super.execute();
}