`
fanggangJava
  • 浏览: 24719 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

在tomcat中设置session过期时间

    博客分类:
  • java
阅读更多

 

1. 在\conf\web.xml中通过参数指定:

<session-config>     
    
<session-timeout>180</session-timeout>       
</session-config>   

单位为分钟。

2. 在程序中通过servlet api直接修改:

HttpSession session = request.getSession();    
session.setMaxInactiveInterval(18
0*60); 

单位为秒,设置为-1永不过期。 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics