我正在使用JSTL来显示列表中的值
<tbody id="tbNa" >
<c:forEach items="${actionBean.excessList.newActiveCustomerExcessUIList}" var="customerExcess" varStatus="loop">
<c:set var="clientName" value="${customerExcess.clientName}"
scope="page"></c:set>
<c:set var="ultimateParent" value="${customerExcess.ultimateParent}"
scope="page"></c:set>
<c:set var="cif" value="${customerExcess.cif}" scope="page"></c:set>
<c:forEach items="${customerExcess.excessList}" var="excess">
<tr>
<td><c:out value="${excess.excessId }"></c:out></td>
<td><c:out value="${excess.openDate }"></c:out></td>
<td><a href="#" onclick="openClientExcessPage('${cif}');" ><c:out value="${clientName}"></c:out></a></td>
<td><c:out value="${ultimateParent}"></c:out></td>
<td><c:out value="${excess.excessAmount }"></c:out></td>
<td><c:out value="${excess.excessDa}"></c:out></td>
</tr>
</c:forEach>
</c:forEach>
如果列表为空,我必须显示“无可用数据”.... 我不知道怎么做......
答案 0 :(得分:1)
您必须使用选择标记
<tbody id="tbNa" >
<c:choose>
<c:when test="${empty actionBean.excessList.newActiveCustomerExcessUIList}">
<tr><td colspan="6">No data available</td></tr>
</c:when>
<c:otherwise>
<c:forEach items="${actionBean.excessList.newActiveCustomerExcessUIList}" var="customerExcess" varStatus="loop">
<c:set var="clientName" value="${customerExcess.clientName}"
scope="page"></c:set>
<c:set var="ultimateParent" value="${customerExcess.ultimateParent}"
scope="page"></c:set>
<c:set var="cif" value="${customerExcess.cif}" scope="page"></c:set>
<c:forEach items="${customerExcess.excessList}" var="excess">
<tr>
<td><c:out value="${excess.excessId }"></c:out></td>
<td><c:out value="${excess.openDate }"></c:out></td>
<td><a href="#" onclick="openClientExcessPage('${cif}');" ><c:out value="${clientName}"></c:out></a></td>
<td><c:out value="${ultimateParent}"></c:out></td>
<td><c:out value="${excess.excessAmount }"></c:out></td>
<td><c:out value="${excess.excessDa}"></c:out></td>
</tr>
</c:forEach>
</c:forEach>
</c:otherwise>
</choose>
答案 1 :(得分:0)
使用c:choose
:
<c:choose>
<c:when test="${empty actionBean.excessList.newActiveCustomerExcessUIList}">
No data available
</c:when>
<c:otherwise>
<table>
...
</table>
</c:otherwise>
</c:choose>
答案 2 :(得分:0)
您可以使用if标签检查列表是否为空
<c:if test="${empty List}">No data available</c:if>