1. forward 前缀: 转发到一个页面或一个 action
不会由我们配置的视图解析器拼串, 独立解析, 一定要加 "/", 不加就是相对路径, 容易出问题;
》转发到 jsp 页面:
- @RequestMapping("/handle")
- public String handle() {
- return "forword:/index.jsp" ;
- }
》转发到 action:
- @RequestMapping("/handle1")
- public String handle1() {
- return "forword:/msg" ;
- }
- @RequestMapping("/msg")
- public String handle() {
- return "forword:/index.jsp" ;
- }
2. redirect 前缀: 重定向到一个页面或一个 action
》重定向到 jsp 页面:
- @RequestMapping("/handle")
- public String handle() {
- return "redirect:/index.jsp" ;
- }
》重定向到 action:
- @RequestMapping("/handle1")
- public String handle1() {
- return "redirect:/msg" ;
- }
- @RequestMapping("/msg")
- public String msg() {
- return "redirect:/index.jsp" ;
- }
来源: http://www.bubuko.com/infodetail-3102055.html