SpringMVC重定向与转发

重定向 , 不需要视图解析器 , 本质就是重新请求一个新地方嘛 , 所以注意路径问题.

@Controller
public class ResultSpringMVC2 {

	@RequestMapping("/rsm2/t1")
	public String test1(){
		//转发
		return "test";
	}
	
	@RequestMapping("/rsm2/t2")
	public String test2(){
		//重定向
		return "redirect:/index.jsp";
		//return "redirect:hello.do"; //hello.do为另一个请求/
	}
}
posted @ 2020-07-30 16:36  iucbjb  阅读(26)  评论(0)    收藏  举报