zoukankan      html  css  js  c++  java
  • Struts清楚session方法

    //第一种方法(继承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

                                

  • 相关阅读:
    ARCGIS JAVASCRIPT API (3.2)部署
    WINFORM 只能运行一个实例问题
    iOS 版本号
    同步和异步的区别
    简单的手机号判断
    "_inflateEnd", referenced from "_inflateInit_"等。这时需要在工程中加入libz.dlib 文件
    iOS 实现打电话
    assign retain copy iOS
    iOS 长按事件 UILongPressGestureRecognizer
    UITableView 滑动删除
  • 原文地址:https://www.cnblogs.com/sungyouyu/p/3873980.html
Copyright © 2011-2022 走看看