当前位置: 首页 > 后端技术 > Java

SpringBoot拦截器排除项失败(-error)的问题

时间:2023-04-02 00:56:22 Java

问题描述如下。将/user/register和/user/login加入排除项后,访问时仍然提示重定向过多/***@author1iin*/@ConfigurationpublicclassMyWebMvcConfigurerAdapterimplementsWebMvcConfigurer{@OverridepublicvoidaddInterceptors(InterceptorRegistry注册表){UserInterceptoruserInterceptor=newUserInterceptor();InterceptorRegistrationloginRegistry=registry.addInterceptor(userInterceptor);//截取路径loginRegistry.addPathPatterns("/**");//排除路径loginRegistry.excludePathPatterns("/user/register");loginRegistry.excludePathPatterns("/user/login");}}解决方法是在请求对应路径的时候发现方法不对应的时候,请求路径会自动转为/error,这就是请求路径无限重定向的原因。

最新推荐
猜你喜欢