session失效后,登录页面嵌入iframe框架

在登录页面的onload方法中加入以下代码解决:

//防止登录页面嵌入iframe框架
if (top.location != self.location){
top.location=self.location;
}

 

其实这么做也不是很完美,因为要加载两次页面,屏幕会有些卡顿;

还有一种方法:

直接在过滤器LoginFilter中,加入以下代码:

 

PrintWriter out = response.getWriter();
out.write("<script>window.parent.location.href = 'default';</script>");

response的时候直接给他制定跳转的action,这样就不会出现上面的问题。

 

posted @ 2016-08-16 17:32  Damon_myblog  阅读(530)  评论(0)    收藏  举报