会话超时配置不起作用?
在 web.xml
中,我有这个
<session-config>
<session-timeout>2</session-timeout>
</session-config>
<listener>
<listener-class>myapplication.SessionListener</listener-class>
</listener>
在 SessionListener.java
中,我有
public void sessionDestroyed (HttpSessionEvent event){
System.out.println("Visitor Removed!!");
}
但似乎 System.out.println("Visitor Removed!!")
从未被执行过。我是 Tomcat 6 和 JSP 的新手。请问有什么建议吗?
In web.xml
I have this
<session-config>
<session-timeout>2</session-timeout>
</session-config>
<listener>
<listener-class>myapplication.SessionListener</listener-class>
</listener>
In the SessionListener.java
I have
public void sessionDestroyed (HttpSessionEvent event){
System.out.println("Visitor Removed!!");
}
But it seems System.out.println("Visitor Removed!!")
has never been executed. I am new to Tomcat 6 and JSP. Any suggestion please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这至少可能有 3 个原因:
sessionCreated()
。sessionDestroyed()
。或者,如果您有更多的耐心,服务器将运行其低优先级计时器作业来获取所有过期的会话。This can have at least 3 causes:
sessionCreated()
as well.sessionDestroyed()
will be called. Or if you have a bit more patience, the server will run its low-prio timer job to reap all expired sessions.myapplication.SessionListener
class in the classpath as you think you're using, maybe the one actually in the classpath doesn't have a sysout line.