Skip to content Skip to sidebar Skip to footer

Thymeleaf + HTML5 - Can't Find JS Or CSS

I'm working on a new application using Thymeleaf that's built upon another one. But instead of fast forwarding the development, I'm stuck on a issue for the better part of the nigh

Solution 1:

By default, Thymeleaf expects us to place templates in the src/main/resources/templates folder.

And for CSS and JavaScript files, the default directory is src/main/resources/static.

Change your resources folder structure to:

src
   main
      resources
         static
            css
            img
            js
         templates
            admin
            fragments
            home
            login.html

CSS usage e.g.

<link th:href="@{/css/beyond-login.css}" rel="stylesheet" />

JS usage e.g.

<script type="text/javascript" th:src="@{/js/beyond.js}"></script>

Post a Comment for "Thymeleaf + HTML5 - Can't Find JS Or CSS"