Spring|Spring Boot拦截器排除项失效的问题( /error )

问题描述 如以下代码,将/user/register与/user/login列入排除项后,在进行访问时,依旧提示重定向次数过多

/** * @author 1iin */ @Configuration public class MyWebMvcConfigurerAdapter implements WebMvcConfigurer {@Override public void addInterceptors(InterceptorRegistry registry) { UserInterceptor userInterceptor = new UserInterceptor(); InterceptorRegistration loginRegistry = registry.addInterceptor(userInterceptor); // 拦截路径 loginRegistry.addPathPatterns("/**"); // 排除路径 loginRegistry.excludePathPatterns("/user/register"); loginRegistry.excludePathPatterns("/user/login"); } }

解决方案 【Spring|Spring Boot拦截器排除项失效的问题( /error )】经查明后发现当请求对应路径时方法不对应时,请求路径会自动转为/error,就是因为这个原因导致了请求路径无限次的重定向

    推荐阅读