【发布时间】:2017-11-02 10:15:56
【问题描述】:
我正在尝试让 Spring Security 允许所有用户访问静态资源,但目前没有任何效果。 在之前的项目中使用jsp的时候,解决方法很简单:
http
.authorizeRequests()
.antMatchers("/static/**").permitAll()
.anyRequest().authenticated()
静态文件夹被放置在 webapp 文件夹中,该文件夹是根文件夹,并且很容易被 Spring Security 检测到。现在,因为 Thymeleaf,没有 webapp 文件夹,所有的静态文件夹都放在 src/main/resources 中。我不知道如何为资源文件夹中的东西创建 antMatcher...我试过了:
http
.authorizeRequests()
.antMatchers("resources:/static/**").permitAll()
.anyRequest().authenticated()
它从来没有奏效。解决办法是什么? 附言。我看过一个声明,Spring Boot + Spring Security 默认允许这种资源内访问,但它不允许。
【问题讨论】:
标签: java spring-boot spring-security