您的位置:首页 > 编程语言 > Java开发

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

2016-03-24 20:59 615 查看

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

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

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

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

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

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: