Исключить пути из перехватчика при весенней загрузкеJAVA

Программисты JAVA общаются здесь
Anonymous
Исключить пути из перехватчика при весенней загрузке

Сообщение Anonymous »

У меня есть простой перехватчик, который проверяет субдомен, и я хочу исключить из него несколько путей. Я следил за документацией Spring и попробовал несколько решений, которые нашел здесь, но ни одно из них мне не помогло. Это мой перехватчик.

Код: Выделить всё

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Autowired
JdbcTemplate jdbcTemplate;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptor() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String subdomain = extractSubdomain(request);
verifySubdomain(subdomain);
return true;
}
}).excludePathPatterns("/**/clientcontrol/**", "/**/localhost/**").pathMatcher(new AntPathMatcher());
}
}
Я также пробовал следующее:

Код: Выделить всё

.excludePathPatterns("/clientcontrol/**", "/localhost/**").pathMatcher(new AntPathMatcher());

.excludePathPatterns("/clientcontrol/**", "/localhost/**");

.addPathPatterns("/**").excludePathPatterns("/clientcontrol/**", "/localhost/**").pathMatcher(new AntPathMatcher());
Но перехватчик все равно срабатывает, и мой метод VerifiedSubdomain выдает исключение.

Подробнее здесь: https://stackoverflow.com/questions/790 ... pring-boot

Вернуться в «JAVA»