开发者

JSP <c:out/> - The default attribute doesn't work?

开发者 https://www.devze.com 2023-01-30 01:33 出处:网络
I\'m having tr开发者_运维问答ouble with the default attribute of the JSP/JSTL tag . The value given for the default-attribute is not displayed.

I'm having tr开发者_运维问答ouble 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消