Develop/[Spring]
[Spring] HandlerInterceptor
HiSmith
2022. 5. 10. 00:27
반응형
prehandle, posthandle, afterCompletion
Filter의 경우, DispatcherServlet이 실행되기 전에 수행되므로, Spring Context에 접근하기 어렵다.
하지만 인터셉터의 경우는, Dispatcher수행 이후에 실행이된다
따라서, Spring Context에 용이하게 접근할 수 있다.
Spring 에서 작성위치는 servlet-context에 작성한다.
Spring boot에서는 WebMvcConfigurerAdapter를 상속, 어떤 컨트롤러를 어떤 url에 매핑할지 정의
인터셉터는 handlerInterceptorAdapter를 상속 받아서 구현 (deprecated) -> HandlerInterceptor를 impl해서 사용
url 기반으로 제어한다. (Aop는 메서드 단위)
매게 변수 HttpservletRequest, HttpServletResponse
반응형