分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

JSP中解决session超时跳转到登陆页面并跳出iframe框架或局部区域的方法

发布时间:2023-09-06 01:07责任编辑:赖小花关键词:暂无标签

//方法1: 重定向到登录页,但是不支持跳出iframe
//response.sendRedirect("/dormitory/toLoginPage");
//方法2:以输出页面并请求到登录页面的形式跳转到登录页面,可以跳出iframe(推荐)
PrintWriter out = response.getWriter(); 
out.println("<html>"); 
out.println("<script>"); 
out.println("window.open (‘/dormitory/toLoginPage‘,‘_top‘)"); 
out.println("</script>"); 
out.println("</html>"); 
return false;

当session会话超时,页面请求被重新定位到了登陆界面。因大都采用Ajax动态局部请求,导致返回登陆页面被嵌套在系统界面的局部区域中,并非想要的效果。一般页面主体布局采用iframe框架进行分割,或者简单实用table等实现同样样式效果,在此简单介绍后台页面重新定向到登陆界面返回前台后,前台进行重新再次定向到登陆界面实现登陆界面无暇。

<script type="text/javascript">
???????  var initScript = setInterval(function(){
???????  if(window.top != null && window.top.document.URL!=document.URL){
???????    clearInterval(initScript);
???????????????????    window.top.location.href = document.URL;
???????  }
???????});
???</script>

JSP中解决session超时跳转到登陆页面并跳出iframe框架或局部区域的方法

原文地址:http://www.cnblogs.com/wanyong-wy/p/7453523.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved