How to get the length of a collection in <c:foreach > tags in jsp

Source: Internet
Author: User

Use the Length property value of the prefix property of the jstl tag functions

1. First import the JSTL function label on the JSP page

<% @ taglib Prefix = " fn " URI = " http://java.sun.com/jsp/jstl/functions " %>

2. For example, set to Messagelist

<items= "${messagelist}"= "message">        <h3>${fn:length (messagelist)}</h3>  </ C:foreach >

This will output the length of the Messagelist collection!

3. Note the difference between the Count property and the following

<items= "${messagelist}"= "message"  varstatus= " Go ">       <h3>${go.count}</h3 >  </ C:foreach >  

Current: The item (in the collection) for this iteration.

Index: The current iteration of this iteration, starting at 0.

Count: The iteration count that is currently starting at 1 for this iteration.

First: Used to indicate whether the current iteration is the initial iteration, which is a Boolean type.

Last: Used to indicate whether the current iteration is the final iteration, which is a Boolean type.

The value of the Begin:begin property.

The value of the End:end property

The value of the Step:step property

How to get the length of a collection in <c:foreach > tags in jsp

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.