• 2019-04-14 EL(Expression Language)


    EL全名为Expression langusage

    它是JSTL 1.0为方便存取数据所定义的语言

     1 <!-- 7. EL 的运算符 -->
     2     ${param.score > 60 ? "及格" : "不及格" }
     3     <br>
     4     
     5     <% 
     6         List<String> names = new ArrayList<String>();
     7         names.add("abc");
     8         request.setAttribute("names", names);
     9     %>
    10     <!-- empty 可以作用于一个集合, 若该集合不存在或集合中没有元素, 其结果都为 true -->
    11     names is empty: ${empty requestScope.names }
    12     <br>
    13     
    14     <!-- 6. 其他隐含对象: pageContext 等(cookie, header, initParam 只需了解.) -->
    15     pageContext: pageContext 即为 PageContext 类型, 但只能读取属性就可以一直的 . 下去。 
    16     <br>
    17     contextPath: ${pageContext.request.contextPath }
    18     
    19     <br>
    20     sessionId: ${pageContext.session.id }
    21     
    22     <br>
    23     sessionAttributeNames: ${pageContext.session.attributeNames }
    24     
    25     <br>
    26     
    27     
    28     initParam: ${initParam.initName }
    29     <br>
    30     
    31     Accept-Language: ${header["Accept-Language"] }
    32     <br>
    33 
    34     JSESSIONID: ${cookie.JSESSIONID.name } -- ${cookie.JSESSIONID.value }
    35     <br>
    36 
    37     <!-- 5. 与输入有关的隐含对象: param, paramValues -->
    38     score: ${param.score }
    39     <%-- 
    40     <%= request.getParameter("score") %>
    41     --%>
    42     <br>
    43     names: ${paramValues.name[0].class.name }
    44     <%-- 
    45     <%= 
    46         request.getParameterValues("name")[0].getClass().getName()
    47     %>
    48     --%>
    49     <br>
    50     
    51     <!-- 4. 隐含对象之与范围相关的: pageScope, requestScope, sessionScope, applicationScope -->
    52     time: ${applicationScope.time.time }
    53     <%-- 
    54     <%= application.getAttribute("time") %>
    55     --%>
    56     <br>
    57     
    58     <!-- 3. EL 可以进行自动的类型转换 -->
    59     score: ${param.score + 11}
    60     <br>
    61     score: <%= request.getParameter("score") + 11 %>
    62     <br>
    63     
    64     <!-- 2. EL 中的隐含对象 -->
    65     <% 
    66         Customer cust2 = new Customer();
    67         cust2.setAge(28);
    68         request.setAttribute("customer", cust2);
    69     %>
    70     
    71     age: ${customer.age } 
    72 
    73     <br>
    74     <!-- 1. EL 的 . 或 [] 运算符 -->
    75     age: ${sessionScope.customer["age"] }
    76     
    77     <%-- 
    78         Customer customer = (Customer)session.getAttribute("customer");
    79         out.print(customer.getAge());
    80     --%>
    81     
    82     <% 
    83         Customer customer = new Customer();
    84         customer.setName("ATGUIGU");    
    85     
    86         session.setAttribute("com.atguigu.customer", customer);
    87     %>
    88     
    89     <br>
    90     <!--  
    91         如果域对象中的属性名带有特殊字符, 则使用 [] 运算符会很方便. 
    92     -->
    93     name: ${sessionScope["com.atguigu.customer"].name }
  • 相关阅读:
    GNU GRUB 2:系统引导器的领导者
    Javascript 返回上一页并刷新
    返回代表指定日期的指定日期部分的整数。返回当前周
    请问如何获取字符串在数组中的位置
    SQL终极优化(包括很多非索引方面的优化和原理)
    td onmouseover="this.style.cursor='hand'" onmouseout="this.style.cursor='normal'" >小手状
    树形菜单
    分页 的首页 rs.absoluteposition=rs.absoluteposition+2+((abs(wzpage)1)*wzrep) 要加2 ??
    JS只弹出一个居中弹出窗口
    一个真实的项目经历,很多东西大家可以借鉴下
  • 原文地址:https://www.cnblogs.com/Codinginging/p/10706582.html
Copyright © 2020-2023  润新知