blog » Java/J2EE » thymeleaf标签th:class使用

thymeleaf标签th:class使用

两种方式都可以使用。

方法1:

<!--/*@thymesVar id="posts" type="java.util.List"*/-->
<span th:each="post:${posts}" th:class="*{'row-'+{id} + ' parent-row-' + {id}}">
<div class="list">
<p th:id="${post.id}" th:text="${post.content}"></p>
<a th:href="@{/delete/__${post.id}__}">删除</a>
<hr/>
</div>
</span>

方法2:

<!--/*@thymesVar id="posts" type="java.util.List"*/-->
<span th:each="post:${posts}" th:class="'row-' + *{id} + ' parent-row-' + *{id}">
<div class="list">
<p th:id="${post.id}" th:text="${post.content}"></p>
<a th:href="@{/delete/__${post.id}__}">删除</a>
<hr/>
</div>
</span>

This post has already been read 70 times!

Related posts

RSS 2.0 | leave a response | trackback

发表评论