1.@Secured
角色判断
1.1 开启注解
App启动类中加入注解
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
1.2 controller层下
@PostMapping("/toIndex")
@Secured("ROLE_aaa") //角色判断
public String toIndex(){
return "redirect:index.html";
}
2.@PreAuthorize
方法执行前使用access表达式判断
2.1 开启注解
2.2 controller层下
@PostMapping("/toIndex")
@PreAuthorize("hasRole('aaa')")//方法执行前判断
public String toIndex(){
return "redirect:index.html";
}
标签:redirect,index,toIndex,Secured,使用,注解,public
From: https://www.cnblogs.com/lwx11111/p/17058157.html