zoukankan      html  css  js  c++  java
  • Java设置session超时(失效)的三种方式

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

    在E:apache-tomcat-7.0.54apache-tomcat-7.0.54confweb.xml中设置,以下是apache-tomcat-7.0.54中的默认配置

    1. <!-- ==================== Default Session Configuration ================= -->  
    2.   <!-- You can set the default session timeout (in minutes) for all newly   -->  
    3.   <!-- created sessions by modifying the value below.    -->  
    4.     <session-config>  
    5.         <session-timeout>30</session-timeout>  
    6. </session-config>  

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


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

    1. <!-- 时间单位为分钟   -->  

    <session-config>

          <session-timeout>15</session-timeout>

    </session-config>

    3.      通过java代码设置

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


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

  • 相关阅读:
    P2324 [SCOI2005]骑士精神
    Codeforces Round #574 (Div. 2) A~E Solution
    P4132 [BJOI2012]算不出的等式
    spring笔记(三)
    spring笔记(二)
    C3P0连接池参数解释
    spring笔记(一)
    hibernate笔记(四)
    hibernate笔记(三)
    hibernate笔记(二)
  • 原文地址:https://www.cnblogs.com/bsyx/p/4011785.html
Copyright © 2011-2022 走看看