I have an if statement that I am trying to perform with JSTL.
My code is below (the variables values is an ArrayList that contains a user defined object and type is a private property of that object, with public getter/setter methods):
<c:forEach items="${list}" var="values">
<c:if test="${values.type}=='object'">
<!-- code here -->
</c:if>
</c:forEeach>
What would be the correct syntax of the part within the test attribute. The docs don’t really help with that part http://download.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/index.html
Thanks.
The comparison needs to be evaluated fully inside EL
${ ... }, not outside.As to the docs, those
${}things are not JSTL, but EL (Expression Language) which is a whole subject at its own. JSTL (as every other JSP taglib) is just utilizing it. You can find some more EL examples here.See also:
By the way, unrelated to the concrete problem, if I guess your intent right, you could also just call
Object#getClass()and thenClass#getSimpleName()instead of adding a custom getter.See also: