zoukankan      html  css  js  c++  java
  • el表达式 多条件判断

    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标签;

      多条件判断符号"&&"和"||",必须在"${}"内;

      判断字符串是否相等,字符串需要加单引号'。

     相关推荐:

  • 相关阅读:
    CAS配置记录
    线程同步机制
    线程
    异常
    List集合
    数据结构
    泛型+通配符高级使用--受限泛型
    Collection集合+迭代器+foreach循环
    easyui获取日期datebox中的值
    EL表达式与三目运算符
  • 原文地址:https://www.cnblogs.com/Marydon20170307/p/9638602.html
Copyright © 2011-2022 走看看