重定向时经常需要带上一定的标志位参数,当然,强大的springmvc提供了便利的操作。
只需要在方法参数中添加RedirectAttributes 或其子类即可!
@RequestMapping("/redirect")
public String redirect(RedirectAttributesModelMap redirect)
{
redirect.addAttribute("redirect", "重定向测试!");
redirect.addAttribute("test", "test!");
System.out.println("重定向");
return "redirect:index.jsp";
}
在jsp页面上获取参数${param.test}