Thymeleaf 排除标签

我们使用th:each循环时 Thymeleaf 模板要输出很多<span>标签,如下代码写法

<span  th:each="location : ${repository.locationInfoList}">

这样前端页面每循环一次都要输出一个<span>,我们希望不输出那么多<span>标识时,那我们可以使用下面解决办法

 

解决办法:

  一、使用th:remove

<span  th:each="location : ${repository.locationInfoList}" th:remove="tag">

  二、使用th:block

<th:block th:text="${name}" />

 

 

 

posted @ 2021-11-09 10:06  千夜大魔王  阅读(315)  评论(0编辑  收藏  举报