JavaSpringBootEleaf不加载静态文件
我的问题和这里提到的一样:Spring Boot Thymeleaf static content doesn´t load
我的项目结构如下所示
但我的场景是:
我在控制台上看到404错误,如:
Request URL:http://localhost:8080/dist/css/meuestilo.css
Request Method:GET
Status Code:404
Remote Address:[::1]:8080
从Spring控制台,我得到:
2017-02-15 23:44:23.160 WARN 8260 --- [nio-8080-exec-4] o.s.web.servlet.PageNotFound : No mapping found for HTTP request with URI [/dist/css/meuestilo.css] in DispatcherServlet with name 'dispatcherServlet'
我的链接标签是:
<link rel="stylesheet" type="text/css" href="/dist/css/meuestilo.css" th:href="@{/dist/css/meuestilo.css}" />
怎么了
模板是根据本教程创建的:http://blog.codeleak.pl/2013/11/thymeleaf-template-layouts-in-spring.html
在更改之前,它工作得非常好
# 1 楼答案
我使用以下方法找到解决方案:
正如这里提到的Thymeleaf Layout Documentation
# 2 楼答案
至于你的第一个链接,我相信你的meuestilo。css应该在static/dist/css/meuestilo中。css 所以你的链接标签应该是这样的