关于java: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");
    }
}

解决方案

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

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理