/**
* session超时跳转登陆页面
* @author zhangdong
* 2017年10月24日
*/
@Aspect
@Component
public class SessionTimeoutAspect { private static Logger logger = Logger.getLogger(SessionTimeoutAspect.class);
public SessionTimeoutAspect() {
} @org.aspectj.lang.annotation.Pointcut("execution(* com.jsz.peini.controller..*.*(..))")
public void controllerPointcut(){
} @Pointcut("execution(* com.jsz.peini.controller.mgr.UserLoginController..*(..))")
public void rootPointcut(){//登录登出功能不需要Session验证
} @org.aspectj.lang.annotation.Pointcut("controllerPointcut()&&(!rootPointcut())")
// @org.aspectj.lang.annotation.Pointcut("controllerPointcut()")
public void sessionTimeOutPointcut(){
} @Around("sessionTimeOutPointcut()")
public Object sessionTimeOutAdvice(ProceedingJoinPoint pjp) throws IOException {
Object result = null;
String targetName = pjp.getTarget().getClass().getSimpleName();
String methodName = pjp.getSignature().getName();
logger.info("----------------执行方法-----------------");
logger.info("类名:"+targetName+" 方法名:"+methodName);
HttpServletResponse response = null;
for (Object param : pjp.getArgs()) {
if (param instanceof HttpServletResponse) {
response = (HttpServletResponse) param;
}
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpSession session = request.getSession();
if(session.getAttribute("MgrUserId")!=null){
try {
result = pjp.proceed();
} catch (Throwable e) {
e.printStackTrace();
}
return result;
} else{
logger.debug("Session已超时,正在跳转回登录页面");
PrintWriter writer = response.getWriter();
writer.write("<script>window.parent.location.href='/superOpAdmin.jsp'</script>");
writer.flush();
writer.close();
}
return result;
}

  

session 超时跳转登陆页面的更多相关文章

  1. session超时跃出iframe并跳到登陆页面(转载)

    session超时跳出iframe并跳到登陆页面 在网页编程时,我们经常需要处理,当session过期时,我们要跳到登陆页面让用户登陆,由于我们可能用到IFrame框架,所以我们我登陆页面需要显示在整 ...

  2. 一步一步实现web程序信息管理系统之二----后台框架实现跳转登陆页面

    SpringBoot springboot的目的是为了简化spring应用的开发搭建以及开发过程.内部使用了特殊的处理,使得开发人员不需要进行额外繁锁的xml文件配置的编写,其内部包含很多模块的配置只 ...

  3. vue定时器+弹框 跳到登陆页面

    1.做一个请求拦截,并弹框提示几秒后,跳转到登陆首页或是点击确定之后直接跳转拦截用了this.$axios.interceptors.response页面上的弹框组件用了vux的组件vux地址:htt ...

  4. ajax提交session超时跳转页面使用全局的方法来处理

    来自:http://www.jb51.net/article/43770.htm 如果是ajax提交,超时时从服务器发出的跳转命令就不会起作用,所以如果是session超时,而且是在ajax请求,就在 ...

  5. dwz ajax session超时跳转登录页(struts2自定义拦截器)

    1.定义struts2拦截器(网上例子很多) 代码如下: package rt.intercepter; import java.util.Map; import javax.servlet.http ...

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

    当session会话超时,页面请求被重新定位到了登陆界面.但登录界面在iframe中的解决方案:在登录页面中加入下面的js代码: <script type="text/javascri ...

  7. iframe登录超时跳转登录页面

    1.可以在登录页面加jQuery验证 $(function () { //判断一下当前是不是做顶层,如果不是,则做一下顶层页面重定向 if (window != top) { top.location ...

  8. SPA项目中,404页面 和 登陆页面 对应的路由,应该怎样控制?

    SPA项目中,404页面 和 登陆页面 对应的路由,应该怎样控制? 可以这样做: 登陆之前,所有页面跳到 登陆页面:包括随便输入的路由地址. 登陆后,跳到相应页面:随便输入的.不存在的路由地址,才跳到 ...

  9. Ajax 提交session实效跳转到完整的登陆页面

    在spring security 中 Ajax提交时,session超时,局部加载登陆页面,为解决这个问题,重写ajax提交,返回的是modeview或者没有制定datatype时; 如果检测到加载到 ...

随机推荐

  1. 利用after和before伪类实现chrome浏览器tab选项卡斜边纯css无图制作笔记

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  2. js 正则表达式 整合

    正则表达式:断言 取字符串区间: /(?<=["+ star +"]).*(?=["+ end +"])/ // 简单封装 Vue.prototype.s ...

  3. pytorch 5 classification 分类

    import torch from torch.autograd import Variable import torch.nn.functional as F import matplotlib.p ...

  4. 调整mysql数据库最大连接数

    1.查看mariadb数据库最大连接数,默认为151 MariaDB [(none)]> show variables like 'max_connections'; +------------ ...

  5. 监控myserver计数器

  6. 洛谷 P2652 同花顺

    P2652 同花顺 题目背景 所谓同花顺,就是指一些扑克牌,它们花色相同,并且数字连续. 题目描述 现在我手里有n张扑克牌,但它们可能并不能凑成同花顺.我现在想知道,最少更换其中的多少张牌,我能让这 ...

  7. android开发面试题

    找了将近两个星期的工作,面试了5家公司,罗列一下笔试或者面试时的问题,祝大家好运 1,handler机制 答:handler执行机制:1).在主线程中创建handler 2).子线程中借助主线程的ha ...

  8. 设计网页录入信息与自己定义server数据接收

    需求:设计一个注冊网页用于录入username和登录password.并将数据传入server并显示出来. 1.前言:网页提交的 get 和 post 两种方式. (1)对于get提交方式,以本文中样 ...

  9. 关于python的hashlib md5的报错处理

    1.报错信息是:TypeError: Unicode-objects must be encoded before hashing 2.报错信息是:TypeError: object supporti ...

  10. Android语音播报、后台播报、语音识别

    Android语音播报.后台播报.语音识别 本文介绍使用讯飞语音实现语音播报.语音识别功能. 讯飞开放平台:http://www.xfyun.cn/index.php/default/index 程序 ...