How to get a zero-based count in a Velocity foreach loop

前端 未结 4 1146
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 02:20

I am trying to get a zero-based counter in a Velocity #foreach directive.

if i use:

#foreach ($item in $list)
   item.getName() : $veloc         


        
4条回答
  •  [愿得一人]
    2021-01-04 03:10

    If you are using Velocity 1.7 there are $foreach.index (0-based) and $foreach.count (1-based) special vars available inside loops.

    $velocityCount is something that was deprecated long time ago afaik.

提交回复
热议问题