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>
* 博客文章部分截图及内容来自于学习的书本及相应培训课程,仅做学习讨论之用,不做商业用途。
* 如有侵权,马上联系我,我立马删除对应链接。
* 备注:王子威
* 我的网易邮箱:wzw_1314_520@163.com
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!