学到 jstl语言的几点注意事项

1.当要在jsp中使用两个条件都是真的时<c:when test="${empty current.procureNew&&current.userByCreater.id==user.id}">,例子如下:

 <c:choose><c:when test="${empty current.procureNew&&current.userByCreater.id==user.id}">
     <a title="<fmt:message key="navigation.edit" />" href="${pageContext.request.contextPath}/updateProjectProcure?idKey=${current.id}&"><img src="${pageContext.request.contextPath}/images/icons/edit.gif" /></a>    
 <a title="<fmt:message key="navigation.delete" />" href="${pageContext.request.contextPath}/deleteOldProjectProcure?id=${current.id}&" onclick='return confirm("<fmt:message key="confirm.if.delete"/>")'><img src="${pageContext.request.contextPath}/images/icons/delete.gif" /></a>
   &nbsp;
    </c:when><c:otherwise></c:otherwise>
    </c:choose>
2.当需要判断一个字段为空时,例如判断一个字符串为空时,<c:when test="${current.memo==null}">

当需要判断的一个对象为空时,则代码如下<c:when test="${empty current.procureNew}">

3.当你觉得<c:choose><c:when></c:when><c:otherwise></c:otherwise></c:choose>来做判断选择不足够时,你可以使用以下的方式:<c:choose><c:when test='${newFlag}'>
<c:if test="${current.enabled==true}"><a href="#" onclick="hit('${current.id}','${current.enabled}');"><fmt:message key="disable" /></a></c:if>
<c:if test="${current.enabled!=true}"><a href="#" onclick="hit('${current.id}','${current.enabled}');"><fmt:message key="enable" /></a></c:if>
   </c:when>
   <c:otherwise>
   <c:if test="${current.enabled==true}"><a href="${pageContext.request.contextPath}/disableOtherUser?idKey=${current.id}&"><fmt:message key="disable" /></a></c:if>
<c:if test="${current.enabled!=true}"><a href="${pageContext.request.contextPath}/enableOtherUser?idKey=${current.id}&"><fmt:message key="enable" /></a></c:if>
   &nbsp;
   </c:otherwise></c:choose>

4、<c:choose><c:when>

<c:choose><c:when></c:when><c:otherwise></c:otherwise></c:choose></c:when>

<c:otherwise><c:choose><c:when></c:when><c:otherwise></c:otherwise></c:choose></c:otherwise></c:choose>这种样式是错误的。

转载于:https://my.oschina.net/u/659230/blog/114032

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值