session - 以分钟和秒为单位的 J2EE session 过期设置

标签 session tomcat web.xml session-timeout

我需要将我的 j2ee 应用程序的 session 到期时间设置为 4 分 30 秒。

据我所知, session 配置部分只允许几分钟。

<session-config>
    <session-timeout>
        [Minute]
    </session-timeout>
</session-config>

我的问题是,是否可以输入小数值,如 4.5(相当于 4 秒 30 秒)?

  <session-config>
        <session-timeout>
            4.5
        </session-timeout>
    </session-config>

最佳答案

Servlet Specification陈述如下

The default time out period for sessions is defined by the servlet container and can be obtained via the getMaxInactiveInterval method of the HttpSession interface. This time out can be changed by the Developer using the setMaxInactiveInterval method of the HttpSession interface. The time out periods used by these methods are defined in seconds

因此您应该能够使用 setMaxInactiveInterval 方法指定 session 超时。

关于session - 以分钟和秒为单位的 J2EE session 过期设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22688109/

相关文章:

c# - 为什么session对象会抛出空引用异常?

ASP.Net session 超时检测 : Is Session. IsNewSession 和 SessionCookie 检测是执行此操作的最佳方法吗?

spring - 带有 Spring 的 Junit - TestContextManager [错误] 在允许 TestExecutionListener 时捕获异常

java - 调用Hibernate session 的close方法后,数据库连接未释放

java - 如何使用属性文件在 web.xml 中设置值?

tomcat - 配置 tomcat 以服务 index.html

php - 为什么我的 cookie 值不能跨页面保留?

php - 如何处理php代码(在ajax中)而不返回任何值

tomcat - Compojure 静态资源在开发中工作但在生产中不工作

java - 如何在 web.xml 中定义一个 url not found servlet 映射?