• web.xml配置Session超时时间注意的单位问题


    为单个Web应用 配置超时时间可以在web.xml中使用<session-config>元素,如

     .... 
    <web-app>
     
    <!--filter.listener,servlet,and servlet-mapping等元素要在session-config之前-->
        
    <session-config>
             
    <session-timeout>15 </session-timeout>
        
    </session-config>
        ... 

    </web-app> 

    这个时候的“15”单位是分钟!

    如果在配置Servlet是指定初始化参数决定超时时间,例如下:

    ....
    <servlet>
        
    <servlet-name>Example</servlet-name>
        
    <servlet-class>exa.mp.le.Example2</servlet-class>
        
    <init-param>
             
    <param-name>timeout</param-name>
             
    <param-value>600</param-value>
       
    </init-param>
    ...
    </servlet>

    这时候的“600”单位是秒钟!

    另外,我们要注意HttpSession.getMaxInactiveInterval()方法返回的是与为单位的;

    session.setMaxInactiveInterval(int seconds)方法参数的单位也是

  • 相关阅读:
    10.3 noip模拟试题
    9.30 noip模拟试题
    9.29 奶牛练习题
    9.29noip模拟试题
    9.28noip模拟试题
    9.27 noip模拟试题
    二维数据结构学习
    9.26 noip模拟试题
    ContentProvider ContentResolver ContentObserver 内容:提供、访问、监听
    Cursor 游标
  • 原文地址:https://www.cnblogs.com/diyingyun/p/3051091.html
Copyright © 2020-2023  润新知