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