【发布时间】:2020-04-16 11:42:22
【问题描述】:
我正在学习 Spring Security,我从https://spring.io/guides/tutorials/spring-boot-oauth2/ 发现了这段代码
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/login**", "/webjars/**", "/error**")
.permitAll()
.anyRequest()
.authenticated();
}
我删除了.antMatcher("/**"),代码仍然有效。
我知道** 匹配路径中的零个或多个目录,所以我认为antMatcher("/**").authorizeRequestes().antMatcher("/login") 会匹配直接或间接在根路径下的"/login",即我希望它匹配像/login 和/demo/login 这样的路径,但那是并非如此,它仅匹配根路径正下方的/login。
那么.antMatcher("/**") here到底需要什么?
【问题讨论】:
标签: java spring spring-boot spring-security