Jstl Tag Collection Traversal summary

Source: Internet
Author: User

After reading this article, the traversal of the front end collection, you can basically handle 90%.

1, rows=list<product>

The list contains entities, the most common, not explained.

<c:foreach items= "${requestscope.rows}" var = "item" ><tr><td>${item.productname}</td> </ Tr> </c:forEach>


2, rows=list<map<string,object>>

The list contains a map, compared to the above, the element does not exist in the form of the entity field, but in the form of a map key value pairs exist. Traverse in exactly the same way as above.

<c:foreach items= "${requestscope.rows}" var = "item" ><tr><td>${item.productname}</td> </ Tr> </c:forEach>


3, rows=list<list<product>>

list, which is generally used for the interface to display a number of different products, each product is a list. Compared to the above, there is a layer of loops.

<c:foreach items= "${requestscope.rows}" var = "itemList" >            <table class= "contenttable" width= "1000" Border= "0" cellpadding= "0" cellspacing= "0" >            <c:foreach items= "${itemlist}" var = "item" >          <tr> <td>${item.productname}</td> </tr></c:forEach>            </table>            </c:foreach >


4, the first selected rows=list<product>

The first product is selected by default.

<c:foreach items= "${requestscope.rows}" var = "itemList" varstatus= "st" >             <c:choose>            <c:when Test= "${st.index ==0}" >            <div class= "fq_boxs fl  selected" >                  <p class= "Termname" > Sub ${ Itemlist.term} period                        <span class= "Termtip" > 0 interest </span>    </p>            </div>            </c: when>            <c:otherwise>            <div class= "Fq_boxs fl" >                    <p class= "Termname" > Sub ${ Itemlist.term} period            <span class= "Termtip" > 0 interest </span></p>            </div>            </c:o therwise>            </c:choose>            </c:forEach>


The World martial arts, only fast not broken. Knowledge is not easy, be good at summing up.

Jstl Tag Collection Traversal summary

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.