• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

Joy奇遇

这个世界上没有天才,只有不努力的笨蛋!!!


博客园    首页    新随笔    联系   管理    订阅  订阅

session失效时间设置

1.      在web容器中设置(此处以tomcat为例)
在tomcat-5.0.28\conf\web.xml中设置,以下是tomcat 5.0中的默认配置:
<!-- ==================== Default Session Configuration ================= -->  
  <!-- You can set the default session timeout (in minutes) for all newly   -->  
  <!-- created sessions by modifying the value below.    -->  
    <session-config>  
        <session-timeout>30</session-timeout>  
</session-config>  
Tomcat默认session超时时间为30分钟,可以根据需要修改,负数或0为不限制session失效时间。

2.      在工程的web.xml中设置
<!-- 时间单位为分钟   -->  
<session-config>
      <session-timeout>15</session-timeout>
</session-config>

3.      通过Java代码设置
session.setMaxInactiveInterval(30*60);//以秒为单位

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

posted @ 2017-11-30 09:34  Joy奇遇  阅读(229)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3