Posts

Showing posts with the label jstl

If a model attribute does not exist, when used with JSTL c:when test for a boolean value, does it always evaluate to false?

Image
Clash Royale CLAN TAG #URR8PPP If a model attribute does not exist, when used with JSTL c:when test for a boolean value, does it always evaluate to false? So for example, if in a jsp we put: <c:choose> <c:when test="${missingAttribute}"> ...do something </c:when> <c:otherwise> ...something else </c:otherwise> </c:choose> If 'missingAttribute' does not exist, will the otherwise block always be executed? In other words, do missing attributes evaluate to false? 2 Answers 2 Yes it will evaluate to false. EL expression specified in an attribute value is processed differently depending on the attribute's type category defined in the TLD. In core when tag, it should evaluate to boolean. In core out tag to String, etc., In your scenario, you need to have c:choose tag enclosing c:when and c:otherwise. <c:if test...