'Thymeleaf and Spring Boot, how to construct assets folder to view html both in runtime and designtime
I have a Spring Boot 2 project and use Thymeleaf template engine. The folder structure is:
main\
resources\
static\
assets\
css\
my.css
js\
templates\
index.html
(1) If I refer my.css as ../static/assets/css/my.css in index.html, I can view index.html directly in browser(file:///path/to/main/resources/templates/index.html) but if I run the project in JetBrains IDEA, and browse it as http://localhost:8080/, the browser console tells can not found my.css.
(2) If I refer my.css as assets/css/my.css in index.html, When I view index.html directly in browser(file:///path/to/main/resources/templates/index.html) the browser tells can not found my.css, but if I run the project in JetBrains IDEA, and browse it as http://localhost:8080/, the browser view becomes OK.
Because Thymeleaf site says it is friendly to both design time, runtime and cooperation with programmer and designer, then can anyone tell me how to construct my static resources and html templates folders relationship to achieve this target? Thanks a lot first!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
