【问题标题】:How to handle session expired in spring web flow?如何处理春季网络流中的会话过期?
【发布时间】:2020-04-16 06:04:39
【问题描述】:

我正在使用 Spring Boot、Spring Web Flow 和 thymeleaf 编写一个 Web 应用程序。当用户会话过期时,注册表单中的 csrf 令牌过期。 如何处理在 Spring Web 流中显示模板文件的会话过期?

【问题讨论】:

标签: spring-boot spring-mvc spring-webflow


【解决方案1】:

Session 应该由 Spring Security 处理。您可以通过添加如下配置将当前用户重定向到另一个页面:

http.sessionManagement()
.expiredUrl("/sessionExpired.html")
.invalidSessionUrl("/invalidSession.html");

在 Thymeleaf 中,您可以使用 session 变量并添加 th:if 属性来检查会话是否存在或类似的东西:

${session.isEmpty()}

查看这个答案https://stackoverflow.com/a/22120387/2230060

【讨论】:

    猜你喜欢
    • 2010-12-23
    • 1970-01-01
    • 2010-12-15
    • 2013-11-01
    • 1970-01-01
    • 2011-02-21
    相关资源
    最近更新 更多