考虑下面的 Spring Security 配置 protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.mvcMatchers("/accounts/*").hasRole("USER")
.mvcMatchers("/accounts/editAccount.htm").hasRole("ADMIN");
}
or
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/accounts/*").hasRole("USER")
.antMatchers("/accounts/editAccount.htm").hasRole("ADMIN");
}
请注意,上面的代码并没有遵循一个良好的实践,即更特别的匹配器应该放在次特别的匹配器之前。然而,按原样使用这代码哪个角
色可以访问"/accounts/editAccount. htm"?(选择一项)