springmvc中返回页面,只在iframe中跳转,而不是整个页面,解决方法。

问题描述:在我写的主页面中用到了iframe,其中在iframe中有一个button点击提交,然后在Controller中返回页面的时候,是在iframe中打开的,而不是整个页面。

最开始我想用ajax来提交表单,然后用parent.location.href()来进行整个页面的跳转,但是不知道为什么,ajax请求一直返回错误,进入error页面,并且我其他的ajax没有问题,坑

最后在用这个方法解决了:

1 @RequestMapping(value = "/test", method = RequestMethod.POST)
2 public String updateUser(HttpServletResponse response){
3         PrintWriter out = response.getWriter();
4         out.print("<script>window.parent.location.href='/account/accountIndex';</script>");
5         out.flush();
6     }
7     return null;
8 }

参考:http://blog.csdn.net/hellostory/article/details/7265357

 

posted @ 2016-03-24 20:59  雨吃草  阅读(2804)  评论(0编辑  收藏  举报