Java 重定向属性消息未显示在html上
我有一个更新会议的控制器类方法。更新此文件时,将检查是否有同名会议,如果有,将抛出带有消息的ConferenceReadyExistException。我将此消息作为FlashAttribute添加到我的RedirectAttributes中,尽管它不会显示在我的html中 我的控制器方法:Java 重定向属性消息未显示在html上,java,html,spring,Java,Html,Spring,我有一个更新会议的控制器类方法。更新此文件时,将检查是否有同名会议,如果有,将抛出带有消息的ConferenceReadyExistException。我将此消息作为FlashAttribute添加到我的RedirectAttributes中,尽管它不会显示在我的html中 我的控制器方法: @PostMapping("/updateConference") public String updateConference( @ModelAttribute(&qu
@PostMapping("/updateConference")
public String updateConference(
@ModelAttribute("conference") @Valid ConferenceDto conferenceDto, BindingResult result, RedirectAttributes attributes) {
if(result.hasErrors()){
attributes.addFlashAttribute("org.springframework.validation.BindingResult.conferenceDto", result);
attributes.addFlashAttribute("conferenceDto", conferenceDto);
return "updateConference";
}
try {
conferenceService.updateConference(conferenceDto);
} catch (ConferenceAlreadyExistException uaeEx) {
attributes.addFlashAttribute("conferenceDto", conferenceDto);
attributes.addFlashAttribute("message", uaeEx.getMessage()); // problem here
return "updateConference";
}
attributes.addFlashAttribute("message", "Successfully modified conference.");
return "redirect:/teacher/configure";
}
在我的html中,我有一行:
<div th:if="${message != null}" th:align="center" class="alert alert-danger" th:utext="${message}">message</div>
消息
你知道为什么会发生这个问题吗