默认情况下,tomcat在停止服务时,会触发onDestory事件,将服务器中保存的所有session信息序列化到硬盘中。这就是为什么我们看到,有时即使服务器重启了,用户依然无需重新登录,如果服务器重启速度够快,则用户会完全感知不到,就好像什么都没发生一样。
有些特殊情况下,我们会设置服务器停止后清除所有的session,不序列化到硬盘。
修改 conf/context.xml
vi conf/context.xml
<Context> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <Manager pathname="" /> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> </Context>
放开 <Manager pathname="" />
删除tomcat的work目录,重启tomcat即可。
上一篇:重构:改善既有代码的设计
下一篇:tomcat设置class热加载
Copyright © 叮叮声的奶酪 版权所有
备案号:鄂ICP备17018671号-1