Thymeleaf模板使用

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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值