I have an interceptor that is supposed to intercept urls with different patterns like:
- myapp/something/add/whatever
- myapp/something/add
- myapp/something/addWhatever
- myapp/something/somethingelse/add
- etc...
I have to intercept all urls which contain "add". There are a lot of somethings and somethingelses...
I have tried different patterns but it seems that they are all wrong:
- **/add/*
- **/add*
- **/add/ ** (I added a blank space before the last ** so it doesn't format it to bold)
The interceptor is something like
public class MyInterceptor implements HandlerInterceptor {
}
I configure it in
@Configuration
@EnableSpringDataWebSupport
@EnableWebMvc
class MvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(final InterceptorRegistry registry) {
registry.addInterceptor(getMyInterceptor()).addPathPatterns("**/add/*", "**/add/**", "**/add*");
}
@Bean
public MyInterceptor getMyInterceptor() {
return new MyInterceptor();
}
}
If I try to access
http://localhost:8080/myapp/something/add/somethingelse
my interceptor doesn't intercept it...