<session-config> <session-timeout>15</session-timeout> </session-config>
<!-- Session失效拦截 -->
<mvc:interceptors>
<!-- 定义拦截器 -->
<mvc:interceptor>
<!-- 匹配的是url路径, 如果不配置或/**,将拦截所有的Controller -->
<mvc:mapping path="/**" />
<!-- 不需要拦截的地址 -->
<mvc:exclude-mapping path="/login.do" />
<bean class="com.cm.contract.controller.annotation.GEISSSessionTimeoutInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
public class SystemSessionInterceptor implements HandlerInterceptor {
private static final String LOGIN_URL="/jsp/sessionrun.jsp";
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex)
throws Exception {
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
HttpSession session=request.getSession(true);
//session中获取用户名信息
Object obj = session.getAttribute(CMConstant.LOGINUSER);
if (obj==null||"".equals(obj.toString())) {
response.sendRedirect(request.getSession().getServletContext().getContextPath()+LOGIN_URL;
return false;
}
return true;
}
<body>
<SCRIPT language="JavaScript">
alert("用户已在其他地方登陆,请重新登录。");
setTimeout(function () {
window.top.location.href="<%=path%>/index.jsp";
},2000);
</script>
</body>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有