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 }

     .

  • 相关阅读:
    黑客是如何知道我们常用的密码的
    一个核物理学霸为何两次收到BlackHat的邀请
    透过大数据剖析漫画何去何从
    SJF(最短作业优先)
    RR(轮转调度算法)
    hrrf(最高响应比)
    fcfs
    Process 2(完成版)
    进程2
    进程1
  • 原文地址:https://www.cnblogs.com/ppcoder/p/7327600.html
Copyright © 2011-2022 走看看