gpt4 book ai didi

Java - 如何在 View 中显示后清除消息

转载 作者:行者123 更新时间:2023-11-29 09:10:36 28 4
gpt4 key购买 nike

我想在我的 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com