Reputation: 171
I'm having trouble with the default attribute of the JSP/JSTL tag . The value given for the default-attribute is not displayed.
<% @ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:out value='value' default="defaultValue"/>
=> Displays value
<c:out value='' default="defaultValue"/>
=> Displays nothing.. // Should have been defaultValue
Why doesn't this work?
Upvotes: 3
Views: 7323
Reputation: 597124
First, you'd better use double-quotes ("
).
Then, ""
is a value - it is an empty string. The default value is used when the value is null
Upvotes: 7