JETT loop 1, 2, 3, 4, 5 for each row

339 Views Asked by At

I use <jt:forEach> Tag to loop but I want add a column to return row number such as:

1, 2, 3, 4, 5

Example 1 fldTest1 fldTest2 2 fldTest1 fldTest2 3 fldTest1 fldTest2 4 fldTest1 fldTest2 ....

Row number starts from 1 and count++

Thanks

1

There are 1 best solutions below

0
On

Check the JETT documentation for the jt:forEach tag (http://jett.sourceforge.net/tags/forEach.html):

Attribute indexVar: This specifies an integer "counter" variable name to be exposed in the beans map. This variable starts at index zero.

Since you want to start at 1, just add one to the value.

For example:

| Index | Employee Name |

| <jt:forEach items="${employees}" var="employee" indexVar="employeeIndex"> ${employeeIndex + 1} | ${employee.name} </jt:forEach>|