如何在Spring Webflow中延长会话持续时间?

问题描述 投票:0回答:1

只要我知道默认会话的持续时间是30分钟,想针对使用Spring创建的特定流程更改此设置Webflow?我的问题是我该如何实现?

我已经研究并找到了一些有趣的文章和解决方案,但是它们似乎都不适合我,而且它们的解决方案也不是很简单

要更改单个请求的会话,我们应该设置HttpSession的setMaxInactiveInterval对吗?因此,如果是这样,我应该在哪里设置呢?在春季编织中?

HttpSession session = request.getSession();
session.setMaxInactiveInterval(10*60);
spring spring-boot spring-webflow spring-session
1个回答
0
投票

要获取Web Flow中的原始HttpSession,您需要使用ExternalContext。像这样:

((HttpServletRequest)
 RequestContextHolder.getRequestContext().getExternalContext()
                     .getNativeRequest())
    .getSession())

https://docs.spring.io/spring-webflow/docs/current/api/org/springframework/webflow/context/ExternalContext.html#getNativeRequest--

© www.soinside.com 2019 - 2024. All rights reserved.