public class LoginHandlerInterceptor extends HandlerInterceptorAdapter{ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler ) throws Exception { String path = request.getServletPath(); if(path .matches(Const.NO_INTERCEPTOR_PATH)){ return true ; } else{ User user = (User)Jurisdiction.getSession().getAttribute(Const. SESSION_USER); if(user !=null){ path = path.substring(1, path.length()); boolean b = Jurisdiction.hasJurisdiction (path ); if(!b ){ response.sendRedirect( request.getContextPath() + Const.LOGIN); } return b ; } else{ response.sendRedirect( request.getContextPath() + Const.LOGIN); return false ; } } }
}
|