Java中session的过时时间配置,session过时的优先级

2014-11-24 11:22:28 · 作者: · 浏览: 3

1. 在web容器中设置(此处以tomcat为例)


在tomcat-5.0.28\conf\web.xml中设置,以下是tomcat 5.0中的默认配置:

[html]




30

[html]




30





30
Tomcat默认session超时时间为30分钟,可以根据需要修改,负数或0为不限制session失效时间。

2. 在工程的web.xml中设置


[html]

[html] view plaincopyprint

15


3. 通过java代码设置

session.setMaxInactiveInterval(30*60);//以秒为单位


三种方式优先级:1 < 2 <3