我在开发 Web 应用程序时使用 tomcat 服务器。我今天看到一种情况。我停止了服务器,并在 5 秒后再次启动。然后上一个会话没有过期。这是什么原因。会话何时过期?
提前致谢..
Whenever Apache Tomcat is shut down normally and restarted, or when an application reload is triggered, the standard Manager implementation will attempt to serialize all currently active sessions to a disk file located via the pathname attribute. All such saved sessions will then be deserialized and activated (assuming they have not expired in the mean time) when the application reload is completed.
This is a quote from Tomcat 7 docs here
You can turn off this behavior by changing the configuration in context.xml:
<Manager>
...
<saveOnRestart>false</saveOnRestart> (by default is true)
</Manager
您可以通过在服务器的 context.xml 文件中设置 saveOnRestart 标志来配置它。尝试将以下行添加到您的 conext.xml 文件中`
<Manager pathname="">
<saveOnRestart>false</saveOnRestart>
</Manager>
`