zoukankan      html  css  js  c++  java
  • 【EL&JSTL】学习笔记

    一、EL表达式(形式:${ })

      1. 1 EL运算符

      •  算术运算符:  +、-、*、/、%

           示例    结果

          ${1+1}    2

          ${1-1}    0

          ${1*3}    3

          ${3/2}    1.5

          ${5%3}    2

      • 关系运算符:大于、小于、等于、不等于、大于等于、小于等于

            示例      结果

          ${2>1}    true

          ${1<0}    false

          ${1==1}     true

          ${3!=2}      true  

          ${5>=2}     true   

          ${4<=3}     false

      • 逻辑运算符: ||、&&、!

                示例          结果

          ${true||true}     true

          ${true||false}    true

          ${false||false}     false

          ${true&&true}     true

          ${true&&false}    false

          ${false&&false}   false

          ${!true}      false

          ${!false}      true

      • 条件运算符:${A?B:C}      

          示例:  ${2>1? "true" : "false"}  结果 true

      • 验证运算符:${empty var}

          String username = "tom";

          ${empty username}  结果 true

      1.2  EL内置对象

      • 域对象 

        •  pageScope
        •  requestScope
        •  sessionScope
        •  applicationScope
      • 输入对象

        •     param    // param.username 相当于 request.getParameter("username");
        •  paramValues  // paramValues.hobby相当于 request.getParameterValues("hobby");
      • Cookie对象

        •  ${cookie.username.value}  //获取cookie中username属性的值       
      • initParam对象

        •    ${initParam.username}  // 获取context对象中的参数值

              如:

                <context-param>

                  <param-name>username</param-name>

                  <param-value>tom</param-value>

                </context-param>

      • pageContext对象

        •  ${pageContext.request.requestURL}  //获取请求URL
        •    ${pageContext.request.queryString}  //获取参数字符串
        •    ${pageContext.request.contextpath}   //获取当前应用目录
        •   ${pageContext.request.method}   //获取请求方式 

      1.3. EL存取器

      •  获取JavaBean数据

           ${sessionScope.person.name}

           ${sessionScope.person.age}

      • 获取Map数据

            // HashMap userInfo= new HashMap();   userInfo.put("username","tom");   userInfo.put("password","123456");

            ${userInfo.username}

            ${userInfo.password}

      • 获取数组数据

             ${names[0]}    // String names = {"tom","lisa","jerry"}

             ${names[0]}

     二、JSTL标签库

      2.1 核心标签库

      •    <c:set var="username" value="value"></c:set>
      •    <c:out value="value"></c:out>
      •    <c:remove var="number"></c:remove>
      •    <c:if test=“ifCondition” var="varName" [scope="{page|request|session|application}"]></c:if>
      •    <c:choose>

                ······

                <c:when test="testCondition">

                </c:when>

                ······

                <c:otherwise>

                </c:otherwise>

             </c:choose>

        <c:forEach [var="varName"] items="collection" [varStatus="varStatusName"] [begin="begin"]  [end="end"] [step="step"]>

          

        </c:forEach>

      2.2 数据库标签库

      2.3 I18N格式化标签库

      2.4 XML标签库

      2.5 函数标签库

  • 相关阅读:
    AdminLTE 3.0发布了
    .NET Core ORM 类库Petapoco中对分页Page添加Order By对查询的影响
    【译】ASP.NET Core在 .NET Core 3.1 Preview 1中的更新
    物品编码中心所说的包装指示符
    Entity Framework Core生成的存储过程在MySQL中需要进行处理及PMC中的常用命令
    Asp.Net Core Mvc Razor之RazorPage
    基于Asp.Net Core MVC和AdminLTE的响应式管理后台之侧边栏处理
    Qt的下载地址
    由于MicrosoftVisualStudio14.0DesignerShadowCache导致的一个异常问题
    Spring系列.事务管理原理简析
  • 原文地址:https://www.cnblogs.com/guoxh/p/7586856.html
Copyright © 2011-2022 走看看