<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.