zoukankan      html  css  js  c++  java
  • EL

    Express Language: replace the function of <%= ..... %> in JSP.

    The grammar of EL: ${ EL content }:

        <%= 1+1 %>  equals ${ 1+1 }

    Where to get the data via EL?

      pageContext, request, session, application the four important domain object.

    The following is a JavaBean class:

    class Person{
      private String name = "pp";
      private String city;
    
      getter/setter;
    }

    To get the Person class's name String in the JSP:

     <%
    
      Person p = new Person();
    
      pageContext.setAttribute("p",p);
    
    %>
    
    name: ${p.name} <%-- the "." means call the getter method fo Person class --%>
    name: ${p["name"]} <%-- has the same function --%>

    Get the data in List:

    <%
         List<String> list = new ArrayList<String>();
         list.add("aaa");
         list.add("bbb");
         list.add("ccc");
         
         pageContext.setAttribute("list", list);
          %>
          
         List:${list[1] }

     Get the data in Map:

    <%
              Map<String,String> map = new HashMap<String,String>();
              
              map.put("a", "aaa");
              map.put("b", "bbb");
              map.put("c", "ccc");
              
              pageContext.setAttribute("map", map);
           %>
    Map:${map.a }

     .

  • 相关阅读:
    ES2017中的修饰器Decorator
    ES6中的模块
    代理(Proxy)和反射(Reflection)
    ES2017中的async函数
    ES6数字扩展
    Promise和异步编程
    ES6定型数组
    ES6数组扩展
    ES6中的类
    ES6中的Set和Map集合
  • 原文地址:https://www.cnblogs.com/ppcoder/p/7327600.html
Copyright © 2011-2022 走看看