el表達式 多條件判斷
CreationTime--2018年9月13日08點59分
Author:Marydon
1.情景展示
ACCESS_ID == 'APP1039' 且 CARDTYPE == 99進入條件體,否則走另外的條件體
2.錯誤用法
<c:when test="${model.personInfo.ACCESS_ID == 'APP1039'} && ${model.personInfo.CARDTYPE == 99}"> <div>頁面展示</div> </c:when>
3.正確方法
方法一
<c:choose> <c:when test="${model.personInfo.ACCESS_ID == 'APP1039' && model.personInfo.CARDTYPE == 99}"> <div>頁面展示1</div> </c:when> <c:otherwise> <div>頁面展示2</div> </c:otherwise> </c:choose>
方法二
<c:if test="${model.personInfo.ACCESS_ID == 'APP1039' && model.personInfo.CARDTYPE == 99}"> <div>頁面展示1</div> </c:if> <c:if test="${model.personInfo.ACCESS_ID != 'APP1039' || model.personInfo.CARDTYPE != 99}"> <div>頁面展示2</div> </c:if>
4.小結
核心標簽庫c沒有 if else 的條件判斷,可以使用c:when和c:otherwise代替;
使用c:when標簽時,該標簽體外必須聲明c:choose標簽;
多條件判斷符號"&&"和"||",必須在"${}"內;
判斷字符串是否相等,字符串需要加單引號'。