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
. Is there something I did wrong? Thank you!
Solved: you can use addPathPatterns()