jsp技术之“如何在jsp中判断属性为空”

一、判断对象列表为空不显示某段代码

<%-- 展开子属性 --%>
<c:if test="${not empty product.variations}">
    <div style="position: absolute; bottom: 0; margin-bottom: 5px;">
        <button type="button" class="btn default" onclick="expandVariations(this, '${product.productSku}')">
            <i class="icon-minus"></i>
        </button>
    </div>
</c:if>

 

二、判断字段是否为true,来决定显不显示代码

<c:if test="${product.productExtend.isAutoPublish}">
    <div>
        <span class="label custom label-success">自动刊登</span>
    </div>
</c:if>

 

 

三、判断如果是执行某些代码,否则显示某些代码

复制代码
<c:choose>
    <%-- 仓库专用标签 --%>
    <c:when test="${product.feature == '重量差异' }">
        <c:if test="${app:auth('11104200') }">
            <span id="product-label-${product.productId }-${feature }"><span class="label label-danger label-sm">${feature }</span></span><br>
        </c:if>
    </c:when>
    <c:when test="${feature == '7天+缺货未发' && isExistAmazonPlatform && department.departmentType == 1}"></c:when>
    <c:otherwise>
        <span id="product-label-${product.productId }-${feature }"><span class="label label-danger label-sm">${feature }</span></span><br>
    </c:otherwise>
</c:choose>
复制代码

 

posted @   骚哥  阅读(859)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示