如何检查 jsp 中的列表是否为空?
How to check that list is empty in jsp?
在服务器端我设置了一个包含列表的属性,如下所示:
List<Gift> gifts = dao.getAllGifts();
request.setAttribute("gifts", gifts);
现在我需要检查一下列表是否为空。那么我该怎么做呢?
<c:if test="${gifts.size is empty}">
<i>The list is empty.</i>
</c:if>
尝试改变这个:
<c:if test="${gifts.size is empty}">
<i>The list is empty.</i>
</c:if>
用这个你可以检查列表是否为空:
<c:if test="${empty gifts}">
<i>The list is empty.</i>
</c:if>
在服务器端我设置了一个包含列表的属性,如下所示:
List<Gift> gifts = dao.getAllGifts();
request.setAttribute("gifts", gifts);
现在我需要检查一下列表是否为空。那么我该怎么做呢?
<c:if test="${gifts.size is empty}">
<i>The list is empty.</i>
</c:if>
尝试改变这个:
<c:if test="${gifts.size is empty}">
<i>The list is empty.</i>
</c:if>
用这个你可以检查列表是否为空:
<c:if test="${empty gifts}">
<i>The list is empty.</i>
</c:if>