本篇文章通过实例为大家讲解Thymeleaf的基本使用。
赋值
基本赋值
<h1 th:text="${name}">默认值</h1>
字符串拼接
普通拼接形式:
<p th:text="'Hello ' + ${name}"></p>
简洁写法:
<p th:text="|Hello ${name}|"></p>
条件判断
条件判断有两种形式:th:if和th:unless。
th:if条件判断:
<a th:if="${isShow == 'true'}" th:href="@{https://www.choupangxia.com/}">官网</a>
th:unless条件判断:
<a th:unless="${isShow == 'no'}" th:href="