Using C:foreach cycle display

Source: Internet
Author: User
Tags foreach

Practice:

I am Wen Haojan:

First of all, the difference between the two, above, before the revision.


Later the effect is:



It is obvious that later the structure of the organization shows that the technology used here is the C tag

Paste the code First:

<c:foreach items= "${babystages}" var= "Pagebabystage" varstatus= "status" > <c:if test= "${status.index%10==0} "> <li data-projectid=" ${pagebabystage.stageid} "class=" open "> <a href=" # "class=" Dropdown-toggle " 
						; <i class= "Icon-list" ></i> <span class= "Menu-text" >${status.index+1}---${status.index+10}</ span> </a> <ul class= "submenu" <c:if test= "${pbstage.stageid==stageone.stageid}" >style= "Displa Y:block; " </c:if> > <c:foreach items= "${babystages}" begin= "${status.index}" end= "${status.index+9}" var= "Pbstage "varstatus=" Cstatus "> <li class=" category <c:if test= "${pbstage.stageid==stageone.stageid}" >active< /c:if> project "data-categoryid=" ${pbstage.stageid} "> <a href=" <spring:url value= '/card/showcard/${pbst
						Age.stageid} '/> ' > <i class= "icon-double-angle-right" ></i>${pbstage.name}</a> </li> </c:foreach> </ul> </li> </c:if> </c:forEach> 

Nested IF in foreach where foreach is nested again.

Backstage to the foreground is babystages this list collection, in the foreground, through the C:foreach to carry out the loop parsing,

will give birth to the effect of the first figure.

If you want to produce the effect of a second graph, it is the code above.

First, you need to cycle through this list, which is 1-10,11-20,21-30 ...

The c:if is used to judge. The index of the Varstatus attribute in C:foreach is used. This attribute, can Baidu a bit c:foreach. In detail, I recommend a website to you:

http://luoke920.iteye.com/blog/258815

Status.index is the index that gets the current iteration starting at 0

And come back to me.

and say c:if.

The c:if I use here is a cyclic condition, which is to give birth to a list of 10.

So, the condition in C:if is

<c:if test= "${status.index%10==0}" >
The iteration starts at 0, that is, the first loop, because it starts with 0, and is actually the first one. It's the 1th-to the 10th one.

When the second cycle, which is from 10, is actually 11 start.


Then, after entering the loop, let him make a c:foreach loop to generate each of the following

<c:foreach items= "${babystages}" begin= "${status.index}"  end= "${status.index+9}" var= "Pbstage" varStatus= " Cstatus ">
	<li class=" category <c:if test= "${pbstage.stageid==stageone.stageid}" >active</c:if > Project "data-categoryid=" ${pbstage.stageid} ">
		<a href=" <spring:url value= '/card/showcard/${ Pbstage.stageid} '/> ' > <i class= "icon-double-angle-right" ></i>${pbstage.name
	}</a> </li>
</c:forEach>
This loop sets the start item of the Loop and the end of the loop.

Begin= "${status.index}"  
When the first time into the For loop, is from the iteration to 0, the actual 1 starts the loop, to the iteration 9, the data of the 10th.

For the second time, enter the For loop, iteration 10, Data 11, to, iteration 19, data 20.

Generated by this.


The begin and end here are the properties of the C:foreach.

The first Static.index is the property of the Varstatus property in C:foreach.

Do not know if you understand, if you do not understand can contact me, I qq:1286238812, notes on the csdn to write on the line. I would like to share my experience with you.

Related Article

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.