问题描述
如以下代码,将/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
,就是因为这个原因导致了请求路径无限次的重定向
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。