重定向
重定向也是web开发中常用的,在springmvc中,重定向相当的简单
@RequestMapping("/index")
public String index(){
return "redirect:hello";
}
轻轻松松,转发给hello.jsp
转发
同样的,转发网页也是一样的方法
@RequestMapping("/index")
public String index(){
return "forward:hello";
}
response.sendRedirect(absolutePath + "/a/forbidden");
重定向和转发都是以HttpRequest为基础的。他们寻找的是controller中的路径。
例如上面的/a/forbidden
是: