Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Where are the javascript resources located in thymeleaf?


Asked by Addyson Coffey on Dec 13, 2021 JavaScript



The CSS static resources are located in the src/main/resources/static/css folder. The JavaScript static resources are located in the src/main/resources/static/js folder.
Keeping this in consideration,
The JAVASCRIPT template mode will allow the processing of JavaScript files in a Thymeleaf application. This means being able to use model data inside JavaScript files in the same way it can be done in HTML files, but with JavaScript-specific integrations such as specialized escaping or natural scripting.
Just so, This tutorial demonstrates how to include static resources to Thymeleaf. We use Spring Boot to start our application. We are loading static resources from the class-path and from org.webjars. The static resources are located in the src/main/resources/static folder. Let’s start by looking at the project structure.
Subsequently,
Thymeleaf templates are just HTML static files (.html extension) that works both in browsers and web applications. By default, these templates are stored in src/main/resources/templates/ folder. Spring Boot automatically picks and renders these HTML files when required.
Consequently,
On application boot time, the message.home property is loaded from the application.yml file. We add this property to the Model which’ll be available to use in the thymeleaf template.