核动力网站建设,广西柳州网站建设价格,wordpress ppt插件,上海关键词优化公司哪家好springSecurity注解使用
在使用springboot的时候#xff0c;大家更习惯于使用注解来进行配置#xff0c;那么springSecurity注解怎么使用呢
首先开启注解
EnableGlobalMethodSecurity(// Spring Security 开启注解securedEnabledtrue, // 开启Secured注解,会创建切点…springSecurity注解使用
在使用springboot的时候大家更习惯于使用注解来进行配置那么springSecurity注解怎么使用呢
首先开启注解
EnableGlobalMethodSecurity(// Spring Security 开启注解securedEnabledtrue, // 开启Secured注解,会创建切点代理Secured注解的方法prePostEnabled true // 开启PreAuthorize和PostAuthorize注解
)Secured
用户具有哪些角色可以访问注意要有ROLE_前缀
Secured({ROLE_student,ROLE_admin}) // 用户具有哪些角色可以访问,注意要有ROLE_前缀
public String test(){System.out.println(secured);return test;
}PreAuthorize
方法进入前进行校验
PreAuthorize(hasAuthority(admin)) // 方法进入前进行校验
public String test(){System.out.println(preAuthorize);return test;
}PostAuthorize
方法结束后进行校验可以正常执行但是返回值需要进行权限校验
PostAuthorize(hasAuthority(admin)) // 方法结束后进行校验可以正常执行但是返回值需要进行权限校验public String test(){System.out.println(preAuthorize);return test;
}PreFilter
允许方法调用但是在进去方法前先过滤输入值
PostFilter
允许方法调用但是会过滤方法的结果 https://zhhll.icu/2021/框架/springSecurity/4.springSecurity注解使用/