- URL를 이용해서 구분
- 특정 URL의 요청이 올 경우 특정 Interceptor를 적용

1. Interceptor Class 선언

HandlerInterceptor interface 구현

preHandle         : Controller 진입 전 
postHandle        : Controller 종료 후
afterCompletion   : JSP 렌더링 후

2. Interceptor 등록

- Legacy의 ***-context.xml 역할

1. Interceptor 설정하는 클래스 선언
2. WebMvcConfigurer Interface 구현
3. class 선언부에 @Configuration 선언
4. addInterceptor 메서드 오버라이딩

@Configuration
@Slf4j
public class InterceptorConfig implements WebMvcConfigurer {
	@Autowired //IOC(Inversion Of Control)
	private TestInterceptor testInterceptor;
	@Autowired
	private StudyInterceptor studyInterceptor;
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//method 체이닝
		//적용할 Interceptor 등록
		registry.addInterceptor(testInterceptor)
		//Interceptor를 적용할 URL 등록
				.addPathPatterns("/qna/**")
				.addPathPatterns("/notice/**")
		//제외할 URL등록
				.excludePathPatterns("/qna/detail")
				.excludePathPatterns("/qna/write");
		
		//추가 Interceptor등록
		registry.addInterceptor(studyInterceptor)
				.addPathPatterns("/qna/**");
	}

}

3. Interceptor 순서

같은 URL로 여러개의 Interceptor가 있는 경우
config class에 등록된 순서대로 적용

4. Method 형식

Interceptor는 Method는 체크 안함
methood 형식으로 구분하고 싶으면
Interceptor내의 pre 또는 post 메서드 내에서
매개변수 request에서 method값을 반환해서 사용

String method = request.getMethod();

if(method.equlas("POST")){
}else {
}