博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java web session过期 跳转页面没有跳出frame的问题
阅读量:7012 次
发布时间:2019-06-28

本文共 834 字,大约阅读时间需要 2 分钟。

  对于frame页面框架的java web项目,如果session过期执行跳转操作时,只在一个frame中(例如center frame)跳转到设置的login页面了,为了能直接跳转到最初的登录页面,就需要在跳转的页面中(login.jsp)添加如下代码:

<script type="text/javascript">

if (top.location != location){
 top.location.href = location.href;
 }
</script>

 

这段代码的含义就是:如果login.jsp不是框架的最外层页面,则改变框架结构,使login.jsp变为框架最外层,这样就实现了跳出frame框架的效果了。

 

以下是java 过滤器的跳转代码

 public class LoginInterceptor implements HandlerInterceptor {

 @Override  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {

  User user = (User) request.getSession().getAttribute("user");  

 if (user != null) {  

  return true;  

 } else {   

 ServletContext context = request.getSession().getServletContext();   

 response.sendRedirect(context.getContextPath() + "/loginController/login");

   return false;    

  }  

}

转载于:https://www.cnblogs.com/DylanZ/p/6169772.html

你可能感兴趣的文章
UPW学习资料整理 .NET C# 转
查看>>
Oracle12c中新建用户
查看>>
分布式编译工具
查看>>
对我而言晦涩的递归
查看>>
React Native 从入门到原理
查看>>
iOS如何随意的穿插跳跃,push来pop去
查看>>
使用maven编译Java项目 http://www.tuicool.com/articles/YfIfIrq
查看>>
【原创】JDK动态代理,此次之后,永生难忘。
查看>>
collection的框架结构
查看>>
c++中的对象复制
查看>>
ubuntu下linux内核源码阅读工具和调试方法总结
查看>>
PHP生成UTF-8编码的CSV文件用Excel打开乱码的解决办法
查看>>
IOS-5个可以帮你优化App的优秀网站
查看>>
ArrayIndexOutOfBoundsException
查看>>
JAVA判断各种类型数据是否为空
查看>>
如何使用kali的Searchsploit查找软件漏洞
查看>>
Vim for Rails developers: Lazy modern configuration
查看>>
十三、Android studio环境的搭建
查看>>
ES6 系列之模板字符串
查看>>
JVM(四)垃圾回收的实现算法和执行细节
查看>>