1. idea 中 Thymeleaf提示:
首先idea中 ctrl + alt + s 可以打开settings 设置界面, 在Plugins中,可以在右侧的搜索中 输入 Thymeleaf,来查看插件是否已经被安装,复选框被选中表示已被安装(一般都是选中的)
在Thymeleaf模板的html页面加入如下:
<html lang="en" xmlns:th="http://www.thymeleaf.org">
这样在输入th: 等标签时就会自动提示。
2.Thymeleaf 标签使用
1. 判断集合数据是否为空:
<div th:if="${#lists.isEmpty(books)}">
<p>You have no books in your book list</p>
</div>
2. 遍历集合数据
<dl th:each="book : ${books}">
<dt class="bookHeadLine">
<span th:text="${book.title}">title</span> by
<span th:text="${book.author}">author</span>
(ISBN: <span th:text="${book.isbn}">ISBN</span>)
</dt>
<dd class="bookDescription">
<span th:if="${book.description}" th:text="${book.description}">Description</span>
<span th:if="${book.description eq null}">No description available</span>
</dd>
</dl>