JSTL 에서
forEach 돌릴 때
index 값을 받아오려면
varStatus 속성을 써야 한다.
varStatus 속성에 변수명을 적어 주고,
그 변수 안에서 index 속성에 접근한다.
예시
<c:forEach items="${orderRecordList}" var="item" varStatus="status">
<tr>
<td><c:out value="${status.index}" /></td>
<td>${item.fruitName}</td>
<td>${item.fruitColor}</td>
<td>${item.fruitPrice}</td>
</tr>
</c:forEach>
-220416
반응형
'Java' 카테고리의 다른 글
[jsp] JSTL과 EL 안에서 문자열 이어붙이는 법 concat() 기능 '+' 연산 (0) | 2022.08.16 |
---|---|
[Java] lambda 에러 : Local variable doesntExistFlag defined in an enclosing scope must be final or effectively final (0) | 2022.04.18 |
Controller로 어떤 parameter들이 넘어오는지 확인하는 방법 (parameter 모두 출력하기) (0) | 2022.04.14 |
ajax로 배열 넘기기 / controller에서 arraylist 받기 (@RequestParam) (2) | 2022.04.14 |
파라미터 DTO를 만들어서 파라미터 여러 개를 한 번에 받기 (0) | 2022.04.14 |