session 超时跳转登陆页面
/**
* 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 超时跳转登陆页面的更多相关文章
- session超时跃出iframe并跳到登陆页面(转载)
session超时跳出iframe并跳到登陆页面 在网页编程时,我们经常需要处理,当session过期时,我们要跳到登陆页面让用户登陆,由于我们可能用到IFrame框架,所以我们我登陆页面需要显示在整 ...
- 一步一步实现web程序信息管理系统之二----后台框架实现跳转登陆页面
SpringBoot springboot的目的是为了简化spring应用的开发搭建以及开发过程.内部使用了特殊的处理,使得开发人员不需要进行额外繁锁的xml文件配置的编写,其内部包含很多模块的配置只 ...
- vue定时器+弹框 跳到登陆页面
1.做一个请求拦截,并弹框提示几秒后,跳转到登陆首页或是点击确定之后直接跳转拦截用了this.$axios.interceptors.response页面上的弹框组件用了vux的组件vux地址:htt ...
- ajax提交session超时跳转页面使用全局的方法来处理
来自:http://www.jb51.net/article/43770.htm 如果是ajax提交,超时时从服务器发出的跳转命令就不会起作用,所以如果是session超时,而且是在ajax请求,就在 ...
- dwz ajax session超时跳转登录页(struts2自定义拦截器)
1.定义struts2拦截器(网上例子很多) 代码如下: package rt.intercepter; import java.util.Map; import javax.servlet.http ...
- JSP中解决session超时跳转到登陆页面并跳出iframe框架或局部区域的方法
当session会话超时,页面请求被重新定位到了登陆界面.但登录界面在iframe中的解决方案:在登录页面中加入下面的js代码: <script type="text/javascri ...
- iframe登录超时跳转登录页面
1.可以在登录页面加jQuery验证 $(function () { //判断一下当前是不是做顶层,如果不是,则做一下顶层页面重定向 if (window != top) { top.location ...
- SPA项目中,404页面 和 登陆页面 对应的路由,应该怎样控制?
SPA项目中,404页面 和 登陆页面 对应的路由,应该怎样控制? 可以这样做: 登陆之前,所有页面跳到 登陆页面:包括随便输入的路由地址. 登陆后,跳到相应页面:随便输入的.不存在的路由地址,才跳到 ...
- Ajax 提交session实效跳转到完整的登陆页面
在spring security 中 Ajax提交时,session超时,局部加载登陆页面,为解决这个问题,重写ajax提交,返回的是modeview或者没有制定datatype时; 如果检测到加载到 ...
随机推荐
- java导出html页面
http://blog.csdn.net/zhyh1986/article/details/8727523#t6 http://blog.csdn.net/zuozuofuwaiwai/article ...
- Build rpm example:zram
rpmbuild #ll zram-1.0.0 total 32 -rw-r--r-- 1 root root 948 Aug 21 16:44 Makefile -rw-r--r-- 1 root ...
- HDU 5288 OO’s Sequence [数学]
HDU 5288 OO’s Sequence http://acm.hdu.edu.cn/showproblem.php?pid=5288 OO has got a array A of size ...
- 定位前后端bug
说明 1 : js是静态资源,会缓存到浏览器的客户端,为了清除缓存,需要强制刷新页面,所有的东西强制的到服务器上拿一下 说明 2 :http状态码,服务器响应的一个状态码,标记不同的处理结果 说明 ...
- JSp获取到当前用户的全部session
<%@page import="java.util.Enumeration"%> <% for (Enumeration<?> e = session ...
- LeetCode 11. Container With Most Water 单调队列
题意 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai ...
- HDU 4856 Tunnels(BFS+状压DP)
HDU 4856 Tunnels 题目链接 题意:给定一些管道.然后管道之间走是不用时间的,陆地上有障碍.陆地上走一步花费时间1,求遍历全部管道须要的最短时间.每一个管道仅仅能走一次 思路:先BFS预 ...
- 零基础学python-5.2 数字表达式操作符
表达式是处理数字最主要的工具 a=1#常量 a=a+1#表达式 操作符 操作符 描写叙述 yield 生成 器函数发送协议 lambda args:expression 生成匿名函数 x if y e ...
- php和js区别
php和js区别 两者在语法上类似,楼上说的对,js=javascript是工作在浏览器端的脚本语言,他所提交的数据是交给浏览器来处理的.但是现在的Ajax技术已经可以把js提交的数据交付到浏览器来处 ...
- mount ntfs 失败解决办法
在双系统中,ntfs可能会应为windows的缓存而挂载失败.可用下面命令修复. Use ntfsfix in the terminal, even if you can't access Windo ...