gpt4 book ai didi

java - Http Session 未过期

转载 作者:行者123 更新时间:2023-11-29 03:23:43 25 4
gpt4 key购买 nike

我在我的应用程序中使用了 spring security,并且在我的 AuthenticationFilter 中添加了以下代码。

request.getSession().setMaxInactiveInterval(60 * 60);

我已远程调试代码并确保在成功验证后执行此代码。我面临的问题是我的 session 不会在 1 分钟后过期。当我检查 session 对象时,我可以看到有一个标志 expiring=false。我不确定这个标志是什么意思。

感谢任何帮助

最佳答案

setMaxInactiveInterval 以秒为单位指定。所以设置为60。

来自 docs :

setMaxInactiveInterval(int interval) Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

关于过期标志

expiring 不是 HttpSession 接口(interface)的一部分。我猜你正在使用 Tomcat,它有一个 StandardSession 基类,它有这样一个 property .根据文档,它是一个 protected 字段,仅用于测试目的。

protected boolean expiring We are currently processing a session expiration, so bypass certain IllegalStateException tests.

大多数情况下,该属性设置为 false 是正常的。

关于java - Http Session 未过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22173227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com