You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot部署至Azure后Flash Attributes无法正常传递问题咨询

Spring Boot搭配Thymeleaf部署Azure后Flash Attributes失效问题

我们在使用Spring Boot搭配Thymeleaf开发应用时遇到了Flash Attributes传递异常问题:本地环境测试时Flash Attributes功能运行正常,但将应用部署到Azure平台后该功能失效,暂不确定是否为Azure禁用了相关能力。

相关代码实现

Java后端逻辑

public void handleInvitationResult(RedirectAttributes redirectAttributes, InvitationResult invitationResult) {
    redirectAttributes.addFlashAttribute("success", invitationResult.isSuccess());
    if (!invitationResult.isSuccess()) {
        redirectAttributes.addFlashAttribute("exception", invitationResult.getErrorMessage());
    }
}

Thymeleaf模板渲染逻辑

<div th:if="${success}" class="mt-3">
    <div class="alert alert-success" role="alert">
        <i class="fas fa-exclamation-circle pr-2"></i><span th:text="#{invitation.success}"></span>
    </div>
</div>

解决方案

经排查问题根源为Spring Boot版本兼容问题,将Spring Boot版本从2.3.5.RELEASE升级至2.5.4即可解决该问题。


内容的提问来源于stack exchange,提问作者geri100

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 17:45:01