public class A {
private String name;
private int age;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setAge(int age) {
this.age= age;
}
public int getAge() {
return age;
}
}
ArrayList list = new ArrayList();
for(int i=1; i <= 10; i++) {
A a = new A();
a.setName("괭이" + i);
a.setAge(i);
list.add(a);
}
request.setAttribute("AList", list);
─────────────────────────────────────────────
<%@ taglib uri="/WEB-INF/tld/jstl/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/jstl/fn.tld" prefix="fn"%>
<!--switch case-->
<c:choose>
<c:when test="${AList!= null && !empty AList}">
<!--for-->
<c:forEach var="one" items="${AList}" varStatus="roop">
${roop.index} : ${roop.count} : ${one.name}, ${one.age}
<br>
<!--if-->
<c:if test="${roop.count == fn:length(AList)}">
- 끝 -
</c:if>
</c:forEach>
</c:when>
<c:otherwise>
리스트가 없습니다.
</c:otherwise>
</c:choose>
─────────────────────────────────────────────
결과.
0 : 1 : 괭이1, 1
1 : 2 : 괭이2, 2
2 : 3 : 괭이3, 3
3 : 4 : 괭이4, 4
...
8 : 9 : 괭이9, 9
- 끝 -


Leave your greetings here.