<!-- th:href with @{} URL expression -->
<link th:href="@{/css/main.css}" rel="stylesheet"/>
<!-- Without server: renders as -->
<link href="/css/main.css" rel="stylesheet"/>
<!-- With context path (e.g. /app): renders as -->
<link href="/app/css/main.css" rel="stylesheet"/>
Static files live in: src/main/resources/static/css/main.css
<!-- th:src with @{} URL expression -->
<script th:src="@{/js/actions.js}"></script>
<!-- Parameterised URL (e.g. with version query param) -->
<script th:src="@{/js/actions.js(v=1.0.0)}"></script>
Static files live in: src/main/resources/static/js/actions.js
<script th:inline="javascript">
// /*[[${expr}]]*/ syntax – Thymeleaf replaces at render time
// The 'default' value after it is the natural template fallback
var courseName = /*[[${courseName}]]*/ 'Default Course';
var totalCount = /*[[${totalCount}]]*/ 0;
</script>
<!-- Rendered output: -->
<script>
var courseName = "Java Web Programming";
var totalCount = 5;
</script>
The buttons below use values injected from the server into JavaScript:
| ID | Name | Score | Grade |
|---|---|---|---|