Java 通过set和out检查jstl变量是否为空

Java 通过set和out检查jstl变量是否为空,java,jstl,Java,Jstl,嘿,我想通过set和out检查jstl变量是否为空 使用set创建了一个变量: <c:set var="prevValue" value="" /> 我使用out方法检查jstl变量是否为空: <c:when test="<c:out value='${empty prevValue}' />" /> empty </c:when> <c:otherwise> not empty </c:otherwise> 空的

嘿,我想通过set和out检查jstl变量是否为空

使用set创建了一个变量:

<c:set var="prevValue" value="" />

我使用out方法检查jstl变量是否为空:

<c:when test="<c:out value='${empty prevValue}' />" />
empty
</c:when>
<c:otherwise>
not empty
</c:otherwise>

空的
不空

但我收到的不是空的。为什么会这样??我确实将prevValue设置为空字符串,所以从技术上讲这是正确的,对吗?

代码将字符串文本放在
c:when
标记的
test
属性中,该属性需要一个布尔值。简化测试表达式以仅检查prevValue是否为空,代码不应包含
代码在
c:when
标记的
test
属性中放入字符串文字,该属性需要布尔值。简化测试表达式,仅检查prevValue是否为空,代码不应包含
已经有一个有效答案

但为什么不简单呢

<c:if test="${not empty prevValue}">

//not empty 

</c:if>

//不空

您已经有了一个有效答案

但为什么不简单呢

<c:if test="${not empty prevValue}">

//not empty 

</c:if>

//不空

@nuttyinbles很高兴它帮了忙:)@nuttyinbles很高兴它帮了忙:)
<c:if test="${not empty prevValue}">

//not empty 

</c:if>