我想在我的 View 中显示错误消息 home.jsp
使用 <c:out value="${message}" />
.但是显示之后,我想清除它。有什么想法吗?
最佳答案
将 RedirectAttributes redirectAttributes
添加到您的 @RequestMapping
函数参数并使用以下方法设置属性:
redirectAttributes.addFlashAttribute("message", "whatever went wrong") ;
return "redirect:/path_to_your_view" ;
记住:这与 Spring 的 redirect:
功能密切相关。
关于Java - 如何在 View 中显示后清除消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12668216/