如何在显示表时将检查放在jsp页面中?

时间:2014-04-03 13:34:37

标签: jsp jstl

如何在显示表格时将支票放入jsp页面?我想检查一下我的jsp页面,如果我的表格中有无数据,它会显示找不到结果而不是空白表。下面是我正在使用的jsp。

<%@ taglib prefix="myFunc" uri="simpleTags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div id="resultContainer">
 <div id="resultChild" class="resultChild">
        <table class="TFtable" style="width: 100%;">
            <tr>
                <th colspan="2" style="font-size: 13px;">${platform} results for "${searchTerm}"</th>
            </tr>
            <tr>
                <td style="font-size: 12px;">
                    <c:forEach var="searchTerm" items="${searchTextResult}" varStatus="position">
                        <c:set var="searchTermDetail" value="${searchTerm}" />
                        <c:set var="productDetail" value="${myFunc:fetchProductDetailsTool(searchTermDetail)}" />
                        <font class="bestResult"> <a class="bestResult" title='<c:out value="${productDetail}"></c:out>'>
                        <c:out value="${searchTermDetail}"></c:out></a></font> ,                                                                                                        
                    </c:forEach>
                </td>
            </tr>
        </table>
        <br>
        <table class="TFtable" style="width: 100%;">
            <tr>
                <th colspan="2" style="font-size: 13px;">Clickstream results for "${searchTerm}" </th>
            </tr>
            <tr>
                <td style="font-size: 12px;">
                    <c:forEach var="searchTerm" items="${searchClickStreamResult}"  varStatus="position">
                        <c:set var="searchTermDetail" value="${searchTerm}" />
                        <c:set var="productDetail" value="${myFunc:fetchProductDetailsTool(searchTermDetail)}" />
                        <font class="bestResult"> <a class="bestResult" title='<c:out value="${productDetail}"></c:out>'>
                        <c:out value="${searchTermDetail}"></c:out></a></font> ,                                                                                                        
                    </c:forEach>
                </td>
            </tr>
        </table>
    </div>
</div>

2 个答案:

答案 0 :(得分:1)

  

如果我的表中没有数据,它将显示“未找到结果”   而不是空白表

<c:choose..确实找到了你想要的东西:

<c:choose>
    <c:when test="${not empty searchTextResult}">
          //table goes here
        </c:when>
    <c:otherwise>Result not found</c:otherwise>
</c:choose>

答案 1 :(得分:0)

<table class="TFtable" style="width: 100%;">
        <tr>
            <th colspan="2" style="font-size: 13px;">${platform} results for "${searchTerm}"</th>
        </tr>
        <tr>
            <td style="font-size: 12px; text-align:center;">
                <c:choose>
                <c:when test="${not empty searchTextResult}">
                <c:forEach var="searchTerm" items="${searchTextResult}" varStatus="position">
                    <c:set var="searchTermDetail" value="${searchTerm}" />
                    <c:set var="productDetail" value="${myFunc:fetchProductDetailsTool(searchTermDetail)}" />
                    <font class="bestResult"> <a class="bestResult" title='<c:out value="${productDetail}"></c:out>'>
                    <c:out value="${searchTermDetail}"></c:out></a></font> ,                                                                                                        
                </c:forEach>
                    </c:when>
            <c:otherwise>Result not found</c:otherwise>
            </c:choose>
            </td>
        </tr>
    </table>