2016-11-03 64 views
0

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

回答

2

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

每当Tomcat是Apache正常关闭并重新启动,或当 应用程序重新加载被触发,该标准Manager实现 将尝试序列化所有当前活动的会话到磁盘文件 通过路径名属性找到。当应用程序重新加载完成时,所有这些已保存的会话将被反序列化并激活(假设它们在 的平均时间内未到期)。

这是可配置的并且可以被禁用:

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