开发者

Grails each tag with iteration

Hey. How can i have a variable in each tag to be an iterator (for exam开发者_开发百科ple, first time run cycle takes value=1, second time value=2, and so on..


The status attribute is what you are looking for. See below:

<g:each collection=${books} var="abook" status="i">
    ${i}
</g:each>

if you call ${i} inside the each tag it will return the current iteration count.

Assuming the books collection contains 5 books, the output will be:

0
1
2
3
4
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜