2个区别搞懂web.xml配置Session超时时间
2012-04-27 09:41
274 查看
为单个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)方法参数的单位也是秒。
<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)方法参数的单位也是秒。
相关文章推荐
- 2个区别搞懂web.xml配置Session超时时间
- 2个区别搞懂web.xml配置Session超时时间
- 2个区别搞懂web.xml配置Session超时时间
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间设置
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- web.xml配置Session超时时间注意的单位问题
- java web.xml设置session过期时间为15分钟,超时却不会过期
- web.xml中配置session超时过滤器
- web.xml配置session过期时间
- web.xml 配置中classpath: 与classpath*:的区别
- servlet中配置文件web.xml中的参数context-param和init-param区别
- web.xml 配置中classpath: 与classpath*:的区别
- Java web.xml session-config 属性配置
- 原博文补充: web.xml配置中ContextLoaderListener和DispatcherServlet的区别: - ContextLoaderListener是在我们的web容器启动的时候启
- Spring 定时任务(精)(session工具类(配置失效时间),cookie工具类 web工程(初始化容器) redis工具类)
- 在web.xml中配置openSessionInView的使用