@RestController("userControllerV1") @RequestMapping("/api/v1/users") public class UserController {
@GetMapping("/me")
@ApiOperation("查询用户详情")
@PreAuthorize("hasAuthority('ROLE_USER')")
public User getDetails(Authentication authentication) {
if (logger.isDebugEnabled()) {
logger.debug("Principal class: {}", authentication.getClass());
}
return (User) authentication.getPrincipal();
}
}
一旦去掉 @PreAuthorize 注解就能访问到,否则授权后直接 404
你看看是不是因为被拦截下来没权限 跳转到一个"未授页面" 那个"未授页面" 是 404