1
我有一個非常簡單的自定義JSP標記,用於生成分頁鏈接。它去大致如下:JSP/JSTL:'2> 10'評估爲true
<span id="${id}" class="paginationLinks ${cssClass}">
<c:if test="${currentPage gt 1}">
<!-- Links to previous page(s) -->
</c:if>
<span class="paginationCurrentPage">
Page ${currentPage}
[DEBUG: current=${currentPage},
total=${totalPages},
show=${currentPage lt totalPages}
inverse=${currentPage gt totalPages}]
</span>
<c:if test="${currentPage lt totalPages}">
<!-- Links to next page(s) -->
</c:if>
</span>
的問題是,鏈接,進入下一個頁面無法顯示的第一頁(currentPage = 1
)之後的。轉到上一頁的鏈接在每個頁面上都能正常工作。我也得到了一些真正怪異的輸出從我的調試塊:
[DEBUG: current=1, total=10, show=true inverse=false] //first page, correct
[DEBUG: current=2, total=10, show=false inverse=true] //second page; 2 > 10 == true? wtf???
[DEBUG: current=9, total=10, show=false inverse=true] //ninth page, still incorrect
[DEBUG: current=10, total=10, show=false inverse=false] //tenth page, correct
兩個currentPage
和totalPages
是long
類型的請求屬性,並通過申報標籤屬性傳遞給標籤。那麼,我做錯了什麼產生如2 > 10 == true
這樣的瘋狂輸出?
更新
它正常工作,如果我用在比較文字10
更換totalPages
,但真的沒有解決不了的問題。
回答你自己的問題的好工作。 –