Jsp c: foreach description

Source: Internet
Author: User

<C: forEach items = "$ {bidList}" var = "bid" varStatus = "status">
<Tr style = "$ {status. index % 2 = 0? 'Background-color: # eeeeee; ': ''}">

<Td style = "width: 110px;"> <c: set var = "str"
Value = "$ {bid. custAccount. custInfo. name}"> </c: set> <c: set
Var = "p1" value = "$ {fn: substring (str, 0, 1)}"> </c: set> <c: set
Var = "p2"
Value = "$ {fn: substring (str, fn: length (str)-1, fn: length (str)}"> </c: set>
<C: out value = "$ {p1}"> </c: out> ***** <c: out value = "$ {p2}"> </c: out>

</Tr>

</C: forEach>


Here we mainly look at the attribute varStatus



<C: forEach varStatus = "status"> description of the varStatus attribute in

We usually use the c tag to traverse the required data. For ease of use, the varStatus attribute allows us to implement functions related to the number of rows, such as odd and even rows; special processing on the last line. Summary of common parameters of the varStatus attribute:

$ {Status. index}: Output row number, starting from 0. $ {Status. count}: output line number, starting from 1. $ {Status. current} The current iteration (in the Set) $ {status. first} checks whether the current item is the first item in the Set, and returns true or false $ {status. last} determines whether the current item is the last item in the set. The returned values are true, falsebegin, end, and step, respectively, indicating the start sequence number, end sequence number, and jump step.
For example, <c: forEach begin = '1' end = '5' step = '2' items = '$ {list}' var = 'item'> indicates: 1 ~ in list collection ~ Five data entries are not cyclically one by one, but each two values are taken. That is, 1st, 3, and 5 data records in the operation set.
Below is a picture I found online. I think it's quite good. I 've added it to my favorites: c: forTokens items = "78.89, 56," delims = "," var = "dailyPrice">
<Tr>
<Td> <c: out value = "$ {dailyPrice}"/> </td> </tr> // separate the numbers with commas (,) as strings! Variable name delims attributes can be added at will. One or more variables can be used as separators.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.