스프링 MVC 인터셉터 설정
1. 설정 : spring-servlet.xml
<!-- Interceptors -->
<interceptors>
<interceptor>
<mapping path="/**" />
<beans:bean class="com.....web.comm.test.SoonInterceptor" />
</interceptor>
</interceptors>
2. 구현 : SoonInterceptor.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SoonInterceptor extends HandlerInterceptorAdapter{
@Slf4j
public class SoonInterceptor extends HandlerInterceptorAdapter{
// postHandle : controller 가 끝나면 처리
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
// TODO Auto-generated method stub
// super.postHandle(request, response, handler, modelAndView);
System.out.println("@@@ soon intercept test -------------------------------------------------");
System.out.println("@@@ request : " + request.getRequestURL());
System.out.println("@@@ response : " + response.getContentType());
System.out.println("@@@ soon intercept test -------------------------------------------------");
}
// afterCompletion : view까지 끝나면 처리
// preHandle : controller 전
}
}