Thymeleaf is a modern server-side java template engine commonly used to build web applications. It is popular in Spring Boot projects for server side rendering of dynamic HTML pages. It has natural templating feature meaning HTML file can be directly opened in browser even without being processed by server. Below is a basic Thymeleaf program that showcases how Thymeleaf can be used with minimal configurations in Eclipse IDE.
1. Adding the Thymeleaf Security dependency in pom.xml
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<form th:action="@{/logout}" method="post" sec:authorize="isAuthenticated()">
<button type="submit">Logout</button>
</form>
No comments:
Post a Comment