Httpsessionlistener:创建了两个会话,但没有会话被销毁

时间:2013-03-01 21:18:55

标签: spring comet server-push httpsession

编辑:我重新提出了问题

我正在使用SpringGWTEventService(与Comet基本相同)。当我创建一个更简单的HttpSessionListener时,我看到 sessionCreated()被调用两次,而sessionDestroyed()之间没有被调用。这是为什么?我有一个用户的两个会话??? 当我第一次在会话bean(HttpSession)上设置一些信息时,会创建第二个Spring

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SomeSessionListener implements HttpSessionListener {

  @Override
  public void sessionCreated(HttpSessionEvent se) {
    log.info("New session was created, source= " + se.getSource());
  }

  @Override
  public void sessionDestroyed(HttpSessionEvent se) {
    log.info("A session was closed");
  } 
}

示例输出:

Application has started
New session was created, source= org.mortbay.jetty.servlet.HashSessionManager$Session:21u4n0rnyp4i@24662444
New session was created, source= org.mortbay.jetty.servlet.HashSessionManager$Session:n9wm8tsj1ote@28925695
Application interrupted by client

1 个答案:

答案 0 :(得分:0)

我找到了一个不同问题的答案: Spring security concurrent-session and HttpSessionListener problem

简而言之: 对会话bean的destroy方法更好。