SORU
12 Mayıs 2009, Salı


JSTL ile boy toplama kontrol edin

Nasıl JSTL ile bir koleksiyon boyutunu kontrol edebilir miyim?

Gibi bir şey

<c:if test="${companies.size() > 0}">

</c:if>

CEVAP
12 Mayıs 2009, Salı


Gönderen: http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/tld-summary.html

uzunluğu( java.lang.Nesne)- Bir dize içinde bir koleksiyondaki öğe sayısını veya karakter sayısını verir.

sayfanın en üstünde bu fn ad izin ver

 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

ve jsp sayfanızda bu şekilde kullanın:

<p>The length of the companies collection is : ${fn:length(companies)}</p>

Bir toplama uzunluğu ile test etmek için:

<c:if test="${fn:length(companies) gt 0}">
   <p>It is greater than 0</p>
</c:if>

> > yerine gt kullanımı jsp/Aksaray etiketleri içinde izin verilmez unutmayın.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ethr95awd

    ethr95awd

    8 Kasım 2006
  • Shameless Maya

    Shameless Ma

    24 Mayıs 2012
  • YAN TV

    YAN TV

    20 EKİM 2011