2012-10-11 179 views
1

我使用下面的代碼。但它總是會轉到其他條件。我檢查了這個值,並且這些從java正確傳遞給了jsp。任何缺失的點?顯示標籤和c選擇標籤

<c:when test="${pCount > 0}"> 
    <display:column class="colPCount" property="pCount " title="${titlePCount}" sortable="true" headerClass="sortable" /> 
</c:when> 
<c:otherwise> 
    <display:column class="colPCount" title="${titlePCount}">&nbsp;-&nbsp;</display:column> 
</c:otherwise> 

對於pcount> 0的項目,仍然在顯示標籤中顯示爲' - '。即使我在第一個條件檢查中反轉檢查條件,如pCount < 0,顯示標記始終顯示其他條件。它總是指向每個價值的其他條件。

編輯:全碼

<display:table class="displayTable" id="itemList" 
     name="${sessionScope.itemList}" requestURI="listItem.action" 
     pagesize="15" defaultsort="2" defaultorder="ascending" sort="list"> 
     <display:column class="colItemName" property="name" 
      title="${titleItemName}" sortable="true" headerClass="sortable"/> 
     ... 
     <c:choose> 
     <c:when test="${pCount > 0}"> 
      <display:column class="colPCount" property="pCount " title="${titlePCount}" sortable="true" headerClass="sortable" /> 
     </c:when> 
     <c:otherwise> 
      <display:column class="colPCount" title="${titlePCount}">&nbsp;-&nbsp;</display:column> 
     </c:otherwise> 
     </c:choose> 
    </display:table> 
+0

告訴我們在哪兒,你在比較 –

回答

1

試試這個方法:${itemList.pCount>0}

+0

當我使用顯示標籤的id像這樣 0}」>時,它工作。 – kitokid

0

我想你可能會不正確地使用顯示標籤庫。如果值大於零,則顯示row.pCount,否則顯示-。但是你實際上在做的是告訴圖書館根據不同的東西(pCount,它可能不存在於你引用的範圍中)來顯示整個列......或者你將不得不向我們展示更多碼)。

嘗試這樣:

<display:column class="colPCount" title="${titlePCount}" sortable="true" headerClass="sortable"> 
    <c:choose> 
     <c:when test="${row.pCount > 0}"> 
      <c:out value="${row.pCount}" /> 
     </c:when> 
     <c:otherwise> 
      &nbsp;-&nbsp; 
     </c:otherwise> 
    </c:choose> 
</display:column> 
+0

兩種情況都是可能的設置'pCount'使用。 – Alex

+0

我試過後它仍然顯示相同的結果。我只需在之前和標記之前添加開始和結束標記。 – kitokid

0

我猜變量pCount = null。嘗試檢查${not empty pCount and pCount>0}

+0

我累了。還是一樣:(只有一件事:那裏不會是pCount的空值。 – kitokid