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
,就是因为这个原因导致了请求路径无限次的重定向推荐阅读
- Activiti(一)SpringBoot2集成Activiti6
- SpringBoot调用公共模块的自定义注解失效的解决
- 解决SpringBoot引用别的模块无法注入的问题
- 2018-07-09|2018-07-09 Spring 的DBCP,c3p0
- spring|spring boot项目启动websocket
- Spring|Spring Boot 整合 Activiti6.0.0
- Spring集成|Spring集成 Mina
- springboot使用redis缓存
- Spring|Spring 框架之 AOP 原理剖析已经出炉!!!预定的童鞋可以识别下发二维码去看了
- Spring|Spring Boot之ImportSelector