简体   繁体   中英

Spring Boot Thymeleaf doesnt load static files

Im having the same problem as mentioned here: Spring Boot Thymeleaf static content doesn´t load

My project Structure is the same as follow.

But my scene is:

Im getting 404 error looking the console, like:

Request URL:http://localhost:8080/dist/css/meuestilo.css
Request Method:GET
Status Code:404 
Remote Address:[::1]:8080

From Spring console, i get:

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'

My link tag is:

<link rel="stylesheet" type="text/css" href="/dist/css/meuestilo.css" th:href="@{/dist/css/meuestilo.css}" />

What is wrong?

The template was created following this tutorial: http://blog.codeleak.pl/2013/11/thymeleaf-template-layouts-in-spring.html

Before changes, it works perfectly!

I find a solution using:

layout:decorator 

As mentioned here Thymeleaf Layout Documentation

在提到您的第一个链接时,我相信您的meuestilo.css应该在static / dist / css / meuestilo.css内部,因此您的链接标记应像这样,

<link rel="stylesheet" href="./dist/css/meuestilo.css">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM