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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM