tutorial example html html5 thymeleaf

html - example - ¿Cómo verificar si la lista está vacía usando thymeleaf?



thymeleaf spring boot (2)

Con Thymeleaf 3.xx puedes validar la lista más elegante:

<div th:if="${!tblUserList.empty}"></div>

o

<div th:if="${!tblUserList.isEmpty()}"></div>

<div th:if="${tblUserList != null}"> --content-- </div>

El código de hoja de tomillo anterior no está funcionando, donde tblUserList es una lista. Por lo tanto, quiero verificar si la lista está vacía en lugar de verificar su nulo. ¿Como hacer eso?


Puedes hacer lo siguiente:

<div th:if="${not #lists.isEmpty(tblUserList)}"> --content-- </div>