zoukankan      html  css  js  c++  java
  • EL表达式的作用与限制条件

    限制条件

      只能访问域对象的数据

    用法

      访问基本数据类型

        首先把数据保存在域对象

          pagecontext.setAttribute("name","eric");

        取处对象

           ${name}

      访问引用数据类型

        输出对象的属性值

           class Student{

              private String name;

              private String id ;

            public String getName(){

                return this.name;        

              }

            public String getId(){

                return this.id;        

              }

            }

        在jsp页面中执行以下代码

         Student student = new Studet();//创建对象

         pagecontext.setAttribute("student","student");//保存到域对象中

         ${student.name}  --${student.id}    //点 代表的是get然后把name首字母大写(调用方法)等价于((Student)pagecontext.findAttribute("student").getName())

         

        输出集合对象

          list集合

            List list = new ArrayList();

            list.add(new Strdent("张三","001"));

            ${list[0].name}-${list[0].id}

            中括号相当于调用getxxx方法本例相当于pagecontext.findAttribute("list").get(0);

          map集合

            Map map = new TreeMap();

            map.put("1000",new Strdent("张三","001"));

            pagecontext.setAttribute("map",map);

            ${map['1000'].name}-${map['1000'].id};

              传入一个key值

    进行算术和比较运算${写入表达式}

      判空的时候也可以用${empty 值}等价于${值==null}

  • 相关阅读:
    《Maven实战》文字版[PDF]
    spring管理的类如何调用非spring管理的类
    从session中获取当前用户的工具类
    WebService,ESB笔记
    Activiti
    ElasticSearch最全分词器比较及使用方法
    [ElasticSearch]Java API 之 滚动搜索(Scroll API)
    从html富文本中提取纯文本
    Jetty启动报Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class
    elasticsearch: 创建mapping
  • 原文地址:https://www.cnblogs.com/hello-liyb/p/7709642.html
Copyright © 2011-2022 走看看