读书人

Spring重定向的两种形式

发布时间: 2012-09-10 11:02:32 作者: rapoo

Spring重定向的两种方式

Spring mvc重定向
两种实现方式:
1、response的重定向

@RequestMapping(value="/common/deleteSmallmajor.action")public ModelAndView deleteSmallmajor(HttpServletRequest request,HttpServletResponse response) throws Exception{                               //.....ModelMap mmap = new ModelMap();mmap.addAttribute("parentId", parentId);mmap.addAttribute("searchSmallmajorName",searchName);mmap.addAttribute("page", this.getPageForDelete(params[1],resultCount));return new ModelAndView("redirect:/common/searchSmallmajorByName.action",mmap);}

??ModelAndView对象作为返回值

第一个参数,我们使用redirect:作为前缀,后面跟随重定向的路径.

第二个参数就是传递的参数,我们用ModelMap封装。

读书人网 >Web前端

热点推荐