2014-04-03 22 views
1

如何在顯示錶格時將支票放入jsp頁面中?我想提出一個檢查我的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> 
+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

Thankyou Rembo它按照我的意願工作。 –

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>