How to get the index of the current iteration of a foreach loop in Struts2, JSTL, FreeMarker
Struts 2
<s:iterator value="userList" status="status" >
<s:property value="#status.index" />
<s:property value="firstname" />
</s:iterator>
JSTL
<c:forEach items="${userList}" var="u" varStatus="status">
<c:out value="${status.index}" />
<c:out value="${u.firstname}" />
</c:forEach>
FreeMarker
<#list userList as u>
${u_index}
${u.firstname}
</#list>
Backend code
List<User> userList = new ArrayList<User>();
userList.add(new User("sam", "jay"));
userList.add(new User("sameera", "jaya"));
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletePython Training in electronic city
DataScience with Python Training in electronic city
AWS Training in electronic city
Big Data Hadoop Training in electronic city
Devops Training in electronic city
blockchain Training in electronic city
Hibernate Training in electronic city