我正在尝试在JSTL中测试一个会话属性是否为空。然而,如果该属性为空,JSTL会将其视为非空属性。
这是我正在尝试用JSTL替换的硬编码。此代码正常工作:
<% if (request.getAttribute("error") != null) { %>
<div class="alert alert-danger">
<strong>Oh snap, something's wrong, maybe the following error could help you out?<br /></strong>
<%= request.getAttribute("error")%>
</div>
<% } %>
这是我如何使用JSTL替换它的方法。在检查时,错误属性不为空,但实际上它是空的。
<c:if test="${not empty sessionScope.error}">
<div class="alert alert-danger">
<strong>Oh snap, something's wrong, maybe the following error could help you out?<br /></strong>
<c:out value="${sessionScope.error}" />
</div>
</c:if>