Reputation: 29805
I am trying to print some html when a choose / when condition is met like this:
<c:choose>
<c:when test="${notification.placeId} == ${place.placeId}">
${notification.name}
</c:when>
<c:otherwise>
placeId: ${place.placeId} - notplaceid: ${notification.placeId}
</c:otherwise>
</c:choose>
This prints: placeId: 50 - notplaceid: 43 placeId: 50 - notplaceid: 47 placeId: 50 - notplaceid: 49 placeId: 50 - notplaceid: 50 placeId: 50 - notplaceid: 51 placeId: 50 - notplaceid: 51 placeId: 50 - notplaceid: 51 placeId: 50 - notplaceid: 51 placeId: 50 - notplaceid: 52 placeId: 50 - notplaceid: 53 placeId: 50 - notplaceid: 0 placeId: 50 - notplaceid: 0
This all prints from the otherwise and never prints the notification name from the when statement. As you can see from the print, the bold output clearly meets the when condition and should print the notification name.
Does anyone know what is going on?
Upvotes: 2
Views: 375
Reputation: 692181
Use
<c:when test="${notification.placeId == place.placeId}">
instead of
<c:when test="${notification.placeId} == ${place.placeId}">
The way you have typed it, the test
attribute is evaluated as a String: the concatenation of the result of the evaluation of ${notification.placeId}
, ==
, and the result of the evaluation of ${place.placeId}
.
You want the whole thing to be evaluated as a boolean expression.
Upvotes: 5