Detailed Jstl of the foreach label

Source: Internet
Author: User

Detailed Jstl of the foreach label

for loop control, it can set the collection (Collection) the members of the group are browsed through it sequentially.

??

? <c:forEach> The syntax of the tag ? Description ? :

Syntax: Iterate over all members of a collection object

<C:foreach[Var= "VarName" ] items= "collection" [varstatus= "Varstatusname" [begin=< Span style= "COLOR: #2a00ff" > "Begin" [end= "End" [ step= "Step" ]>

???????? Ontology Content

</c:foreach>

<c:forEach> Label's ? Property Description ? :

?

<c:forEach> Label's ? Properties :? varstatus property: It provides four additional properties : Index,count,fist and the Last , they have a self-meaning as follows :

Property

Type

Significance

index

number

count

number

first

boolean

Last

Boolean

Now refers to whether the member is the last

?

?

Example:

Servlet Code:

map<string, string> map = new hashmap<string, string> ();

Map. Put ("1", "a");

Map. Put ("2", "B");

Map. Put ("3", "C");

Request. SetAttribute ("Map", map);

Request. Getrequestdispatcher ("3.jsp"). Forward (request, response);

?

JSP Code:

<C:foreachvar= "entry" Span style= "COLOR: #7f007f" >items= " ${map} " varstatus= "status" begin< Span style= "Color:black" >= "0" end= " ${map.size ()} " step= "1" >

???? Entry.key: <c:outvalue="${entry.key}"/>|

???? Entry.value: <c:outvalue="${entry.value}"/ >|

????????

???? Status.index: <c:outvalue="${status.index}"/>|

???? Status.count: <c:outvalue="${status.count}"/>|

???? Status.first: <c:outvalue="${status.first}"/ >|

???? Status.last: <c:outvalue="${status.last}"/>

???? <br />

</C:foreach>

?

The output is:

?

?

?

Reference documents:

JSTL label Reference Manuals

Detailed Jstl of the 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.