인터셉터 파일 생성
- TestInterceptor.java
public class TestInterceptor extends HandlerInterceptorAdapter {
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
System.out.println("preHandle");
return true;
}
}
인터셉터 설정
ApplicationConfiguration.java
public class ApplicationConfiguration implements WebMvcConfigurer {
private TestInterceptor testInterceptor;
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(testInterceptor)
.addPathPatterns("/**")
.excludePathPatterns("/public/**" ,"/css/**" ,"/images/**" ,"/js/**" ,"/error/**" ,"**.ico" );
}
}