問題描述:在我寫的主頁面中用到了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
