【问题标题】:i want to show my error message from controller to html thymleaf spring boots我想显示我从控制器到 html thymeleaf spring boots 的错误消息
【发布时间】:2023-01-04 22:56:32
【问题描述】:
if(checkcode.isPresent()){          
            redirectAttributes.addFlashAttribute("errorMessage", "This products have already !");
            return "redirect:/save-product";
            
        } else if (checkname.isPresent()) {
            
            redirectAttributes.addFlashAttribute("errorMessage", "This product have already !");
            return "redirect:/save-product";
}
<div th:if="${errorMessage}">
    <div th:text="${errorMessage}"></div>
</div>

这是我的控制器,我的 div 向 thymeleaf 显示错误消息,但这个不会显示在我的 thymeleaf 页面上

【问题讨论】:

    标签: javascript arrays json spring


    【解决方案1】:

    addFlashAttribute() 修改为 addAttribute()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 2019-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多