1、知识点:
1)、return ``"forward:/jsp/result.jsp"``;请求转发。
2)、return ``"redirect:/jsp/result.jsp"``;请求重定向。
这里要想传递数据的话,需要使用之前介绍过的Model实现,这里的数据同样会放在url中,所以只能传递基本数据类型和String类型。
请求转发。
@RequestMapping("/redirectStr.do")public String redirectStr(School school, Model model)throws Exception{//这里的数据同样会放在url中,所以只能传递基本数据类型和String类型model.addAttribute("schoolName", school.getSchoolName());model.addAttribute("address", school.getAddress());return "forward:/jsp/result.jsp";}
请求重定向。
@RequestMapping("/redirectStr.do")public String redirectStr(School school, Model model)throws Exception{//这里的数据同样会放在url中,所以只能传递基本数据类型和String类型model.addAttribute("schoolName", school.getSchoolName());model.addAttribute("address", school.getAddress());return "redirect:/jsp/result.jsp";}
