【发布时间】:2019-03-02 18:10:11
【问题描述】:
我们正在使用 Spring webflow + ThymeLeaf 并尝试在 html 页面中访问 session.getAttribute()。
对 Thymeleaf 有点陌生,我知道 Thymeleaf 有两种方法来处理会话,即。 ${session.something} 和 ${#session.getAttribute('something')}。
我们使用的代码如下所示,偶尔会失败。
<div th:if="${(#session.getAttribute('booleanAttribute'))}">
...
</div>
在本地环境中,我从来没有看到失败,它按预期工作。在生产中,这失败了。 30 分钟内 200 次出现以下错误 -
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "(#session.getAttribute('booleanAttribute'))" (template: "base" - line 80, col 10)
我不太愿意在不了解为什么在本地正常工作的情况下进行空检查以查看 (#session) 是否为空。所以我有这个问题 -
上面可能有什么问题,我如何在本地重现,以便确认我放置的修复程序适用于所有环境?
【问题讨论】: