关于java:Spring-Boot拦截器排除项失效的问题-error

8次阅读

共计 565 个字符,预计需要花费 2 分钟才能阅读完成。

问题形容

如以下代码,将 /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");
    }
}

解决方案

经查明后发现当申请对应门路时办法不对应时,申请门路会主动转为 /error,就是因为这个起因导致了申请门路有限次的重定向

正文完
 0