1、知识点:
1)、在重定向到其他controller中的方法的时候,只要保证两者的参数名一致即可实现数据的传递。
2)、 mv.setViewName("redirect:other.do"); 使用重定向到其他Controller的other.do,此时springmvc.xml配置文件中的视图解析器将会失效
@RequestMapping("/redirectMAV.do")public ModelAndView redirectMAV(School school,String name)throws Exception{ModelAndView mv = new ModelAndView();mv.addObject("name", name);mv.addObject("schoolName", school.getSchoolName());mv.addObject("address", school.getAddress());System.out.println(school.getAddress());//使用重定向,此时springmvc.xml配置文件中的视图解析器将会失效mv.setViewName("redirect:other.do");return mv;}
RequestMapping("/other.do")public ModelAndView other(String name, School school)throws Exception{ModelAndView mv = new ModelAndView();//单个接收mv.addObject("name", name);//通过javabean对象接收mv.addObject("school", school);System.out.println(school.getAddress());mv.setViewName("result");return mv;}
