session過期跳轉到登陸頁面並跳出iframe框架的兩個方法
阿新 • • 發佈:2019-02-10
HttpServletRequest req = (HttpServletRequest) request;
Visitor visitor = (Visitor) req.getSession().getAttribute("visitor");
if (visitor == null)
{
((HttpServletResponse) response).sendRedirect("/smpc/login/login.jsp");
}
chain.doFilter(request, response);
User user = (User) req.getSession().getAttribute("session_user"); if (user == null) { java.io.PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<script>"); out.println("window.open ('/smpc/login/login.jsp','_top')"); out.println("</script>"); out.println("</html>"); return; } 方法二: 在你想控制跳轉的頁面,比如login.jsp中的<head>與</head>之間加入以下程式碼: <script language="JavaScript"> if (window != top) top.location.href = location.href; </script>