-1

I am learning Spring Boot and using Thymeleaf in my project. When I replace the header code as a separate file in the same folder and use Thymeleaf's replace syntax, the CSS, JS, and Bootstrap code is not displayed on the website. When I try to run it on port 8080, only the HTML code is displayed without the CSS, JS, or Bootstrap.

log output error 2024-05-17T09:44:23.684+05:30 WARN 17192 --- [nio-8081-exec-1] actStandardFragmentInsertionTagProcessor : [THYMELEAF][http-nio-8081-exec-1][home.html] Deprecated unwrapped fragment expression "footer :: footer" found in template home.html, line 353, col 6. Please use the complete syntax of fragment expressions instead ("~{footer :: footer}"). The old, unwrapped syntax for fragment expressions will be removed in future versions of Thymeleaf.

this is the syntax i use

directory image enter image description here

header file enter image description here

2
  • the problem is likely to be in header.html - it has to have a fragment defined (e.g. <div th:fragment="header">) see thymeleaf.org/doc/articles/layouts.html Commented May 17, 2024 at 7:00
  • please post actual code (not only images) Commented May 17, 2024 at 9:12

1 Answer 1

0

I see that you refer to the CSS file like this:

<link rel="stylesheet" href="/static/css/style-starter.css">

Spring Boot serves what is inside the static folder on the root, so you should use something like this:

<link rel="stylesheet" th:href="@{/css/style-starter.css}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.