我需要在重定向后显示一条“消息”,modelAndView
但是众所周知,这是不可能的,然后,我使用redirectView,但我不知道如何显示视图。总之,我需要改变这个:
ModelAndView model = new ModelAndView("product/edit");
在
RedirectView redirectView = new RedirectView("product/edit");
我需要在重定向后显示一条“消息”,modelAndView
但是众所周知,这是不可能的,然后,我使用redirectView,但我不知道如何显示视图。总之,我需要改变这个:
ModelAndView model = new ModelAndView("product/edit");
在
RedirectView redirectView = new RedirectView("product/edit");
You can store message as session
scope attribute and then redirect to jsp page where you can access it back using JSP Standard Tag Library and Expression language.
Controller:
@RequestMapping(...)
public String method1(...){
...
session.setAttribute("message", "Hello, How are you?");
return "redirect:product/edit";
}
Note: Here you can use RedirectView
as well.
JSP:
${sessionScope.message}