사용 this 게시물 컬렉션에 값이 하나 뿐이며 문자열 인 경우 Collection 개체가 아닌 String으로 반환됩니다. 내 문제는 내 컬렉션 Integer에서 BigDecimal에 이르기까지 아무것도 컬렉션에 반환 된 문자열 수 있습니다. JSTL 조건 아래에서 사용했다면 String 타입의 데이터 만 잡는다. 다른 유형은 어떻습니까?JSTL : 개체가 컬렉션인지 아닌지 확인하는 방법
여기서 queryResults
은 객체 배열 목록을 포함합니다 : List<Object[]>
. 따라서 bookmark
은 객체의 배열이됩니다 : Object[]
<c:forEach var="bookmark" items="${queryResults}" varStatus="loopStatus">
<tr class="${loopStatus.index % 2 == 0 ? 'roweven' : 'rowodd'}">
<c:choose>
<c:when test="${bookmark.getClass().simpleName == 'String'}">
<!--The collection has only 1 record and that is of type String. Can't run for loop. -->
<td><c:out value="${bookmark}"/></td>
</c:when>
<c:otherwise>
<!--The collection has more than 1 record therefore running a for loop. -->
<c:forEach begin="0" end="${fn:length(bookmark)-1}" varStatus="loop" >
<td><c:out value="${bookmark[loop.count-1]}"/></td>
</c:forEach>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
, 나는 알게되었다 Object가 String인지 컬렉션인지 여부를 JSTL로 찾는 방법. –
에서 말씀하지
–'queryResults' 컬렉션에는 정확히 무엇이 들어 있습니까? –