Are you using Thymeleaf? I use it in combination with Kotlin and Spring.
When writing conditional statements, if you write them using tags like div
, they will be included in the output. I’ll introduce a way to use logical blocks instead.
Environment
- Thymeleaf 2.1.4
Method
Use th:block
.
1 2 3 4 5 6 7 8 9 10 |
<th:block th:if="${condition}"> something you want to show </th:block> <th:block th:switch="${value}"> <th:block th:case="1"> </th:block> <th:block th:case="2"> </th:block> </th:block> |