[Struts2] invalidate session 和 新建 session

invalidate:

 ((org.apache.struts2.dispatcher.SessionMap<String, Object>) session).invalidate();

http://struts.apache.org/2.0.14/docs/how-do-we-get-invalidate-the-session.html

创建新session:

  不需要自写代码。因为当你用session.put(xxx,xxx)时,Struts2如果发现当前没有httpSession就会自己新建一个。

//org.apache.struts2.dispatcher.SessionMap
    public V put(K key, V value) {
        synchronized (this) {
            if (session == null) {
                session = request.getSession(true);
            }
        ....
      }
   

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.