解決session過期跳轉到登錄頁並跳出iframe框架

當用戶長時間停留在管理界面沒有操作,等到session過期後,進行了操作,那麼只是iframe跳轉到login頁面,這不是我們想要的結果。

方法一:
在login頁面加一個邏輯判斷:

<script >
$(document).ready(function () {  
    if (window != top) {  
        top.location.href = location.href;  
    }  
});
</script>

方法二:

HttpSession session = request.getSession();
      String LOGIN_ID = (String) session.getAttribute("LOGIN_ID");
      if (null == LOGIN_ID||"".equals(LOGIN_ID)) {
          java.io.PrintWriter out = response.getWriter();  
          out.println("<html>");  
          out.println("<script>");  
   out.println("window.open ('"+request.getContextPath()+"/login.jsp','_top')");  
           out.println("</script>");  
           out.println("</html>");  
           return;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章