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
精彩评论