I am adding inceprtors by exposing a bean in a following way:
@Bean
public WebMvcConfigurer webMvcConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(cacheClearanceInterceptor()).addPathPatterns("/*")
.order(OFFSET + 1);
registry.addInterceptor(pageNotFoundInterceptor()).addPathPatterns("/*")
.excludePathPatterns("/static/*").order(OFFSET + 2);
}
};
}
I am using SimpleUrlHandlerMapping for resolving url to handler methods. However, I don't see above interceptors added. I was expecting spring will add interceptors but it's not and request hits to handler method directly without interceptors in the middle. Do I need to call setInteceptors method manually to register inceptors on SimpleUrlHandlerMapping ?