jstl if else 判斷


<c:choose>
<c:when test="${userInfo.cardPhoto1 != null && userInfo.cardPhoto1 != '' }">
<img src="<%=ProjectConfig.getFileServers()%>${userInfo.cardPhoto1} " onerror="javascript:this.src='imgs/ic_pic_l.png';" style="padding:0px;width: 197px;height: 122px;cursor:pointer;"/>

</c:when>
<c:otherwise>
<img src="imgs/ic_jiahao.png" style="cursor:pointer;"/>
</c:otherwise>
</c:choose>

java web javaEE ,jsp EL表達式和JSTL標簽if-else if-else四種用法
一.條件運算符

${user.gender==1?'男':'女'}

二.if()

<c:if test="${2>1}">code..</c:if>

code會在test屬性為true時執行

 

三.if()-else{}

 

<c:choose>

  <c:when test="${2>1}">code..</c:when>

  <c:otherwise>code..</c:otherwise>

</c:choose>

四.if()-else if()-else{}

<c:choose>

  <c:when test="${2>1}">code..</c:when>

  <c:when test="${2>3}">code..</c:when>

  <c:otherwise>code..</c:otherwise>

</c:choose>

注意,第二個when標簽只有在第一個條件不滿足,滿足第二個條件時執行

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM