解决session过期跳转到登陆页面并跳出iframe框架
2014-08-31 17:17
555 查看
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://www.blogbus.com/peony07-logs/74217064.html
当session过期后可以用过滤器来设置重定向页面。
public class ActionFilter extends HttpServlet implements Filter {
private FilterConfig filterConfig;
public void init(FilterConfig config) {
this.filterConfig = config;
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
HttpServletRequest req = (HttpServletRequest) servletRequest;
servletRequest.setCharacterEncoding("UTF-8");
HttpServletResponse res = (HttpServletResponse) servletResponse;
String url = req.getRequestURI();
SysUserVOImpl user = (SysUserVOImpl) req.getSession().getAttribute("SysUser");
if (null == user) {
if (!COMMON.isEmpty(url) && (url.endsWith("newestlogin.jsp") || url.endsWith("UserLoginAction.jsp") || url.endsWith("login.jsp") || url.endsWith("loginAction.do"))) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
req.getRequestDispatcher("/newestlogin.jsp").forward(req, res);
}
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
}
但是这样不能不能跳出iframe等框架。
可以用javaScript解决
在你想控制跳转的页面,比如login.jsp中的<head>与</head>之间加入以下代码:
<script language="JavaScript">
if (window != top)
top.location.href = location.href;
</script>
则在系统超时想在框架中打开登录页时,则login.jsp自身进行判断后跳出iframe等框架。
这段时间一直在休息, 很久没写了,写点简单的吧。要开始学习啦!!!
当session过期后可以用过滤器来设置重定向页面。
public class ActionFilter extends HttpServlet implements Filter {
private FilterConfig filterConfig;
public void init(FilterConfig config) {
this.filterConfig = config;
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
HttpServletRequest req = (HttpServletRequest) servletRequest;
servletRequest.setCharacterEncoding("UTF-8");
HttpServletResponse res = (HttpServletResponse) servletResponse;
String url = req.getRequestURI();
SysUserVOImpl user = (SysUserVOImpl) req.getSession().getAttribute("SysUser");
if (null == user) {
if (!COMMON.isEmpty(url) && (url.endsWith("newestlogin.jsp") || url.endsWith("UserLoginAction.jsp") || url.endsWith("login.jsp") || url.endsWith("loginAction.do"))) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
req.getRequestDispatcher("/newestlogin.jsp").forward(req, res);
}
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
}
但是这样不能不能跳出iframe等框架。
可以用javaScript解决
在你想控制跳转的页面,比如login.jsp中的<head>与</head>之间加入以下代码:
<script language="JavaScript">
if (window != top)
top.location.href = location.href;
</script>
则在系统超时想在框架中打开登录页时,则login.jsp自身进行判断后跳出iframe等框架。
这段时间一直在休息, 很久没写了,写点简单的吧。要开始学习啦!!!
相关文章推荐
- Jsp中解决session过期跳转到登陆页面并跳出iframe框架的方法
- 解决session过期跳转到登陆页面并跳出iframe框架
- 解决session过期跳转到登陆页面并跳出iframe框架
- [置顶]解决session过期跳转到登陆页面并跳出iframe框架
- 解决session过期超时跳转到登陆页面并跳出iframe框架
- 解决session过期跳转到登陆页面并跳出iframe框架
- Jsp中解决session过期跳转到登陆页面并跳出iframe框架的方法
- 解决session过期跳转到登陆页面并跳出iframe框架
- 解决session过期跳转到登陆页面并跳出iframe框架
- session过期跳转到登陆页面并跳出iframe框架的最简单方法
- session过期跳转到登陆页面并跳出iframe框架
- session过期跳转到登陆页面并跳出iframe框架的两个方法
- Form验证 解决过期超时跳转到登陆页面并跳出iframe框架
- 解决session过期跳转到登录页并跳出iframe框架
- 解决session过期跳转到登陆页面并跳出iframe框架
- 当session过期后自动跳转到登陆页而且会跳出iframe框架
- 解决session过期跳转到登陆页面并…
- java web session过期 跳转登录页面,怎么跳出iframe的问题
- session过期后含用iframe框架页面如何自动跳转到登陆页