01
02/23
Spring Security 中的自定义PreAuthorize 注解
controller: @NeedAdmin @GetMapping(path ="user", produces ="application/json") publicResponseEntity<User> getUser(@RequestParamString login){ ... } 自定义注解anno: @PreAuthorize("hasAuthority('Admin')") @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface NeedAdmin { }