2

Thymeleaf唯一块级标签th:block使用(标签本身不显示)

 1 year ago
source link: https://blog.51cto.com/abcd/6047226
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Thymeleaf唯一块级标签th:block使用(标签本身不显示)

精选 原创

清风凌雪 2023-02-09 17:31:35 博主文章分类:前端 ©著作权

文章标签 Thymeleaf 文章分类 Html/CSS 前端开发 yyds干货盘点 阅读数167

th:block是一个属性容器,是Thymeleaf提供的唯一的一个块级元素,可以使用<th:block></th:block>定义片断块,并在里面添加任何的th属性;

特殊性在于Thymeleaf模板引擎在处理th:block的时候会删掉它本身,标签本身不显示,而保留其内容,在循环的时候特别有用。

<th:block>

</th:block>

比如说循环输出一个表格行的内容

<table>
<th:block th:each="user:${userList}">
<tr>
<td th:text="${user.userId}"></td>
<td th:text="${user.userName}"></td>
<td th:text="${user.userAge}"></td>
<td th:text="${user.userSex ? '男':'女'}"></td>
</tr>
</th:block>
</table>
  • 打赏
  • 收藏
  • 评论
  • 分享
  • 举报

上一篇:Java中调用js方法


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK