<div align="right">
<b> Connected:</b> <%=(String)session.getAttribute("CONNECTION_DBNAME")%>
</div>
- 我在jsp页面中有上述代码
- 最初 session CONNECTION_DBNAME 没有任何值。
- 当CONNECTION_DBNAME为空时,我需要显示未连接
- 当 CONNECTION_DBNAME 具有值时,会打印某些值。
- 我知道可以通过使用带有条件的 if else 来实现,但我不知道如何在 jSTL 标记内使用 if else 。
最佳答案
<c:if test="${sessionScope.CONNECTION_DBNAME!= null}">
Connected:${sessionScope.CONNECTION_DBNAME}
</c:if>
<c:if test="${sessionScope.CONNECTION_DBNAME== null}">
NOT CONNECTED
</c:if>
or
<c:choose>
<c:when test="${sessionScope.CONNECTION_DBNAME != null}">
Connected:${sessionScope.CONNECTION_DBNAME}
</c:when>
<c:otherwise>
NOT CONNECTED
</c:otherwise>
</c:choose>
关于javascript - jsp 页面中的 jSTL 标记中的 if else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15132526/