有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Tomcat如何管理会话?

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


共 (1) 个答案

  1. # 1 楼答案

    默认的tomcat配置是将会话状态持久化到磁盘,并在下次启动时重新加载。根据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