所以我正确加载了静态CSS文件,然后由于某种原因,不知道为什么,它们停止了正确加载。 这是我的项目结构:
在index.html中导入:
<head>
<link rel="stylesheet" th:href="@{/css/styles.css}"/>
</head>
我什至尝试在 application.properties
中设置 spring.resources.static-locations=classpath:/static/
但无济于事。
最精彩的部分是:
检查网站时 - styles.css
作为 index.html
加载到 templates
文件夹中。
做什么?
最佳答案
在 Spring Security 4.x 中 - Spring Security 中的资源为 permitAll
。
在 spring security 5.x 中 - 你应该手动配置它。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/css/**", "/js/**").permitAll()
}
关于java - Thymeleaf 错误加载静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54716579/