學到 jstl語言的幾點注意事項

1.當要在jsp中使用兩個條件都是真的時<c:when test="${empty current.procureNew&&current.userByCreater.id==user.id}">,例子以下: jsp

 <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}"> spa

當須要判斷的一個對象爲空時,則代碼以下<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>
字符串

四、<c:choose><c:when> it

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

<c:otherwise><c:choose><c:when></c:when><c:otherwise></c:otherwise></c:choose></c:otherwise></c:choose>這種樣式是錯誤的。 test

相關文章
相關標籤/搜索