To get the loop index in Velocity template,
we need to initiate a temporary index variable, and increase the variable count by 1 after every occurrence in the loop.
the idea is what we have in the for loop.
Done!!
we need to initiate a temporary index variable, and increase the variable count by 1 after every occurrence in the loop.
#set( $count = 1 )
<table>
#foreach( $customer in $customers )
<tr>
<td>$count</td>
<td>$customer.name</td>
<td>$customer.age</td>
</tr>
#set( $count = $count + 1 )
#end
</table>
the idea is what we have in the for loop.
int count = 1;
for(Customer c : customerList) {
print(...);
count++;
}
Done!!
No comments:
Post a Comment