Blame view

src/com/fh/interceptor/LoginHandlerInterceptor.java 1.07 KB
ad5081d3   孙向锦   初始化项目
1
2
3
4
5
6
7
8
  package com.fh.interceptor;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
  import com.fh.entity.system.User;
  import com.fh.util.Const;
  import com.fh.util.Jurisdiction;
ad5081d3   孙向锦   初始化项目
9
10
11
12
13
14
15
16
17
18
19
20
  public class LoginHandlerInterceptor extends HandlerInterceptorAdapter{
  
  	@Override
  	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
  		// TODO Auto-generated method stub
  		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());
4f32cbf7   孙向锦   更新新东方服务界面维护文档
21
  				boolean b = true;//Jurisdiction.hasJurisdiction(path); //访问权限校验
ad5081d3   孙向锦   初始化项目
22
23
24
25
26
27
28
29
30
31
32
33
34
  				if(!b){
  					response.sendRedirect(request.getContextPath() + Const.LOGIN);
  				}
  				return b;
  			}else{
  				//登陆过滤
  				response.sendRedirect(request.getContextPath() + Const.LOGIN);
  				return false;		
  			}
  		}
  	}
  	
  }