转载自: http://blog.csdn.net/jackyrongvip/article/details/4607653
最近在spring mvc中遇到了如何实现页面跳转的问题.比如在页面A中的提交按钮用户提交后,需要重定向到另外一个新的页面,并且有可能要把一些参数带过去.
这其实在实现中有两个方法
1 在controller中实现redirect,可以使用sendRedirect()方法,然后返回
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { ........ response.sendRedirect("photohouxuandetail.do?pid="+pid); return null; }
2 还可以用redirect来实现,这样viewResolver认为是重定向操作,不再渲染该视图了,而是直接向客户端发出redirect响应
return new ModelAndView("redirect:photohouxuandetail.do?pid="+pid);