我有一个PRODUCT字段,它在JSP中有两个字段(SELECTED&TOTAL COST)。 如果产品不是EMPTY,但我可以检索字段名称和值 产品为空时,无法将字段值(SELECTED&TOTAL COST)显示为空白。 根据要求,这两个字段值如果为空,则应显示为空白。
我使用,但是它循环了多次, 它不会显示空白字段
实际代码:
<tr>
<td class="panelLabel" style="text-decoration: underline;">PRODUCT:</td>
<td class="panelValue"></td>
</tr>
<c:forEach items="${applicationDetails.application.product}" var="product">
<c:if test="${not empty product and (fn:toUpperCase(product.isPlanSelected) eq 'Y')}">
<c:set var="isAtleastOneSelected" value="yes"></c:set>
<tr>
<td class="panelLabel">SELECTED:  </td>
<td class="panelValue"><c:out value="${product.isPlanSelected}"/></td>
</tr>
<tr>
<td class="panelLabel">TOTAL COST:  </td>
<td class="panelValue"><fmt:formatNumber type="currency" value="${product.totalCost}"/></td>
</tr>
</c:if>
</c:forEach>
我尝试过的代码:
<tr>
<td class="panelLabel" style="text-decoration: underline;">PRODUCT:</td>
<td class="panelValue"></td>
</tr>
<c:forEach items="${applicationDetails.application.product}" var="product">
<c:choose>
<c:when test="${not empty product and (fn:toUpperCase(product.isPlanSelected) eq 'Y')}">
<c:set var="isAtleastOneSelected" value="yes"></c:set>
<tr>
<td class="panelLabel">SELECTED:  </td>
<td class="panelValue"><c:out value="${product.isPlanSelected}"/></td>
</tr>
<tr>
<td class="panelLabel">TOTAL COST:  </td>
<td class="panelValue"><fmt:formatNumber type="currency" value="${product.totalCost}"/></td>
</tr>
</c:when>
<c:otherwise>
<tr>
<td class="panelLabel">SELECTED:  </td>
<td class="panelValue"></td>
</tr>
<tr>
<td class="panelLabel">TOTAL COST:  </td>
<td class="panelValue"></td>
</tr>
</c:otherwise>
</c:choose>
</c:forEach>
附带的屏幕截图
product_expected1 - should display like this if product is empty product_expected2 - should display like this if product is not empty