Is it possible to detect java class type using El with JSTL?
Asked Answered
O

1

8

code is like this:

 <c:forEach  items="${itemList}" var="item">
 //do stuff based on the class type of item                                 
 </c:forEach>

Is it possible to do that? Thanks!

Oceania answered 10/2, 2011 at 15:30 Comment(0)
C
15

Yes, ${item.class} conforms to the javabeans convention, so you get the Class. Then you can get other properties.

If it doesn't work, use ${item['class']}

Ctenidium answered 10/2, 2011 at 15:33 Comment(1)
According to issues.apache.org/bugzilla/show_bug.cgi?id=50120 class is a reserved word in jsp, too. So you have to use ${item['class']}Chatterton

© 2022 - 2024 — McMap. All rights reserved.