英文:
Thymeleaf. How to hide element based on boolean parametr?
问题
我有一个评论表格
<table class="table">
<tbody>
<tr th:each="review : ${reviewsForMovie}">
<td th:utext="${review.text}"></td>
</tr>
</tbody>
</table>
但如果 review.isApproved == false
,我不想显示评论<br>
我该如何做到这一点?
英文:
I have a table of reviews
<table class="table">
<tbody>
<tr th:each="review : ${reviewsForMovie}">
<td th:utext="${review.text}"></td>
</tr>
</tbody>
</table>
But I dont want to show review if review.isApproved == false
<br>
How do i do that?
答案1
得分: 0
<table class="table">
<tbody>
<tr th:each="review : ${reviewsForMovie}">
<td th:hidden="${!review.isApproved}" th:utext="${review.text}"></td>
</tr>
</tbody>
</table>
英文:
<table class="table">
<tbody>
<tr th:each="review : ${reviewsForMovie}">
<td th:hidden="${!review.isApproved}" th:utext="${review.text}"></td>
</tr>
</tbody>
</table>
专注分享java语言的经验与见解,让所有开发者获益!
评论