Spring MVC

Thmyleaf

spring mvc

  • Fragment on the page : <div th:replace="header :: myheader"></div>

  • Fragment page : <div th:fragment="myheader">

  • Link css and js files : <link th:href="@{/bootstrap.css}" rel="stylesheet">

  • loop over list

<tr th:each="employee : ${employeeList}"> 
	<td th:text="${employee.firstName}"></td> 
	<td th:text="${employee.email}"></td> 
</tr>

Dynamic button route

<a th:href="@{/showFormForUpdate/{id}(id=${employee.empId})}"> </a> 

<a th:href="@{/deleteEmpl/{id}(id=${employee.empId})}" method="DELETE"> </a> 

Route

<a th:href="@{/saveEmpForm}"> </a> 

Conditional Rendering

<div th:if="${true}">This Element will be visible</div>` 

Form example

Last updated

Was this helpful?