el表达式的判断

EL判断语句


<!-- currentRoleId是存在request域中的、sysAdmin是存在application域中的,即servletContext中 -->
<c:if test="${empty currentRoleId}">
     currentRoleId为空
</c:if>
<c:if test="${not empty currentRoleId}">
     currentRoleId不为空
</c:if>

<!-- 判断两者是否相等 -->
<c:if test="${requestScope.currentRoleId eq applicationScope.sysAdmin}">
     currentRoleId和sysAdmin相等
</c:if>

<!-- 在这里就不是和empty一样了,在这里el表达式不相等不像判断是否为空那样,不为空是not empty,在这里不相等不是not eq,表示不相等应如下所示的取反操作 -->
<c:if test="${!(requestScope.currentRoleId eq applicationScope.sysAdmin)}">
     currentRoleId和sysAdmin不相等
</c:if>


<!-- 不使用jstl判断,使用三目表达式输出 -->
${!(requestScope.currentRoleId eq applicationScope.sysAdmin) ? "两者不相等" : "两者相等"}

${not empty currentRoleId ? "不为空" : "为空"}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值