简体   繁体   English

Springboot 拦截器 exceludePathPatterns

[英]Springboot interceptor exceludePathPatterns

I have a controller class shown below:我有一个如下所示的控制器类:

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    UserService userService;

    @PostMapping("/roleChange")
    public Map<String, Object> setUserRole(String uuid, String email, String roleId){
        return userService.setUserRole(uuid, email, roleId);
    }
}

And this is how I added the interceptor to registry:这就是我将拦截器添加到注册表的方式:

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login","/user/role-control");
    }
}

It seems like this still intercepted a request to /role-control .似乎这仍然截获了对/role-control的请求。 Is there something I did wrong?是不是我做错了什么? Thank you!谢谢!

已解决:您可以使用addPathPatterns()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM