Jsp:foreach Label

Source: Internet
Author: User

This tag is used to iterate the output of a series of objects in a Collection collection, and can specify the number of iterations. The general use format is as follows:

<c:foreach items= "collection" var= "VarName" [varstatus= "Varstatusname"][begin= "Begin"] [end= "End"] [step= "Step"] >body content</c:foreach>

  

The attributes used in this tag are described below:
var: the name of the object that is saved in the Collection collection class.
Items: The collection class name that will be iterated.
Varstatus: Stores the state information of an iteration and can access information about the iteration itself.
Begin: If the begin value is specified, it means that the iteration starts from Items[begin], and if no begin value is specified, the set
The first value of the hop begins the iteration.
End: Ends when iterating to the end of the collection, and if no end value is specified, represents the last of the collection in the iteration
-bit
Step: Specifies the step size of the iteration.

<%string items[] = new String[5];items[0] = "core Tag library"; Items[1] = "internationalization tag"; items[2] = "SQL Tag"; items[3] = "xml tag"; Items[4] = "Function Tag library";Request.setattribute ("items", items);%><b></b><c:out value= "does not specify the iteration of Begin:"/></b><c:foreach var= "item" items= "${items}" > <c:out value= "${item}"/><br></c:foreach><b><c:out value= "Specify the iteration of Begin and end"/>< /b><c:foreach var= "Item" items= "${items}" begin= "1" end= "3" step= "1" > <c:out value= "${item}"/><br ></c:foreach><b><c:out value= "Output information for the entire iteration"/></b><c:foreach var= "item" items= "${items} "Begin=" 3 "end=" 4 "step=" 1 "varstatus=" s "><c:out value=" ${item} "/> Four properties <br> location, index <c:out value=" ${s.index} "/><br> iterative: <c:out value=" ${s.count} "/><br> is the first location: <c:out value=" ${s.first} "/ ><br> is the last location: <c:out value= "${s.last}"/><br></c:foreach>

  

Jsp:foreach Label

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.