举个例子:
.authorizeRequests()
.antMatchers("/file/**").authenticated()
.antMatchers("/company/**").authenticated()
我拦截了/company/下所有的请求都需要认证之后才行
那么 如果我不想认证,这时我又想用访问比如:/company/getAllCompany这个资源呢?
肯定有小伙伴说用这个
.antMatchers("/company/getAllCompany").permitAll()
没错 就是这个 可是又有问题? 那就是顺序问题了
应该这样写
.authorizeRequests()
.antMatchers("/company/getAllCompany").permitAll()
.antMatchers("/file/**").authenticated()
.antMatchers("/company/**").authenticated()
/company/getAllCompany释放这个请求需要定义在拦截/company/**的前面,先对其开放再拦截就行了