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

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

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

     相关推荐:

  • 相关阅读:
    SVN访问配置及常用操作
    SVN配置
    在Eclipse中创建maven项目
    Maven的基础之环境配置
    线程池理解
    JVM之类的生命周期
    JAVA代码编程规范
    Jquery实现div局部页面刷新中js渲染失效问题解决
    觅踪17
    第十四周进度
  • 原文地址:https://www.cnblogs.com/Marydon20170307/p/9638602.html
Copyright © 2011-2022 走看看