gpt4 book ai didi

java - Tomcat 是如何管理 session 的?

转载 作者:行者123 更新时间:2023-11-28 22:40:38 25 4
gpt4 key购买 nike

当我重新启动 tomcat 容器时,如果我停止 tomcat,我的应用程序应该转到索引页面(或登录页面),但它允许我转到那个 View 。当我从 eclipse 中删除 tomcat 并重新创建 tomcat 服务器并启动时,它只会重定向到索引。tomcat 如何管理我在之前的服务器启动时创建的 session ?

最佳答案

默认的 tomcat 配置是将 session 状态保存到磁盘并在下次启动时重新加载。来自 tomcat 文档 [1]:

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.

这是可配置的,可以禁用:

Every web application by default has standard manager implementation configured, and it performs session persistence across restarts. To disable this persistence feature, create a Context configuration file for your web application and add the following element there:

<Manager pathname="" />

[1] 官方文档:http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Disable_Session_Persistence

关于java - Tomcat 是如何管理 session 的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40396125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com