【问题标题】:JSF session disappear after refreshing the page刷新页面后JSF会话消失
【发布时间】:2016-05-08 14:34:23
【问题描述】:

我尝试在 JSF 会话中保存 idname,但它们没有被存储。

当我刷新页面时它消失了。 这是我正在使用的代码:

HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.setAttribute("id", 123);
session.setAttribute("name", "a name");

我想通过会话做的是使用过滤器保护我的页面,并在其中测试会话是否存在

请帮帮我

问候

【问题讨论】:

  • 请有人回答我

标签: jsf jakarta-ee


【解决方案1】:

我解决了我的问题:D

我有一个会话范围的 ManagedBean,当页面刷新时它消失了。所以问题是会话在 1 秒或更短的时间内到期。所以我将setSessionMaxInactiveInterval 设置为-1 禁用会话过期超时:

FacesContext.getCurrentInstance()
            .getExternalContext()
            .setSessionMaxInactiveInterval(-1);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-20
    • 1970-01-01
    • 2019-05-16
    • 2013-01-22
    • 2014-08-16
    • 2013-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多