📅  最后修改于: 2023-12-03 14:47:58.473000             🧑  作者: Mango
Thymeleaf is a popular Java-based template engine used for server-side rendering in web applications. It provides a seamless integration with Spring Framework and can be easily configured in IntelliJ IDEA, a popular Java IDE. In this guide, we will discuss how to set up the Thymeleaf HTML xmlns in IntelliJ IDEA.
Before setting up Thymeleaf in IntelliJ IDEA, make sure you have the following prerequisites:
Follow the steps below to set up Thymeleaf HTML xmlns in IntelliJ IDEA:
<!-- For Maven projects -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<!-- For Gradle projects -->
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
}
To use Thymeleaf in your HTML files, follow these steps:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Thymeleaf HTML Example</title>
</head>
<body>
...
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Thymeleaf HTML Example</title>
</head>
<body>
<h1 th:text="${pageTitle}"></h1>
<ul>
<li th:each="user : ${users}" th:text="${user.name}"></li>
</ul>
</body>
</html>
In the above example, ${pageTitle}
and ${users}
are Thymeleaf expressions that will be evaluated and replaced with dynamic content during rendering.
By following the steps mentioned in this guide, you can easily set up Thymeleaf HTML xmlns in IntelliJ IDEA. Thymeleaf provides powerful templating capabilities for creating dynamic web pages in Java-based web applications. Make sure to refer to the Thymeleaf documentation for more detailed usage and features.