0

我正在使用 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>

如果列表为空,我必须显示消息“无可用数据”......我不知道该怎么做......

4

3 回答 3

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>
于 2013-05-13T07:35:09.637 回答
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>
于 2013-05-13T07:34:46.337 回答
0

您可以使用 if 标签来检查列表是否为空

<c:if test="${empty List}">No data available</c:if>
于 2013-05-13T07:36:40.387 回答