How can I solve thymeleaf css not found error?

Issue

How can I solve thymeleaf css not found error?

The bootstrap.min.css file is located in resources/templates/css/bootstrap.min.css.
The following sources were used to refer to this file.

<head>
     <meta charset="UTF-8">
     <link th:href="@{/css/bootstrap.min.css}"
           href="../css/bootstrap.min.css" rel="stylesheet">
     <title>Title</title>
     </style>
</head>

The result rendered on the server is <link href="/css/bootstrap.min.css" rel="stylesheet">.

If you access the address
I get an error GET http://localhost:8080/css/bootstrap.min.css net::ERR_ABORTED 404.

How can I solve this problem?

Best Regards

Solution

Create a directory called static under resources/templates/ and move css directory into it. The css and js should be in a directory called static so that the framework recognises them. The path for the css file should look as follows:

resources/templates/static/css/bootstrap.min.css

Answered By – deepakchethan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published