我有这个控制器的方法:
@RequestMapping(value="/path", method = RequestMethod.GET )
public String path(Model model, RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("attr", "valueFromPath");
return "redirect:jspPage.jsp";//this page located in webApp folder
}
jspPage.jsp:
...
<h1>${attr}</h1>
...
在我的情况下,这一行是空的,但我希望它valueFromPath
会显示在这个 jsp 上。
我怎么能做到?
网页.xml:
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
...
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>