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}

  • 相关阅读:
    静态类和静态类成员(C# 编程指南)
    sealed(C# 参考)
    C#高级知识点概要(2)
    线程并发和异步
    CXF+Spring+Hibernate实现RESTful webservice服务端实例
    Spring Boot 实现RESTful webservice服务端实例
    Spring Boot 实现RESTful webservice服务端示例
    Spring Boot REST API 自动化测试
    Biee插入图形时报错-超过了已配置的已允许输出提示, 区域, 行或列的最大数目
    BIEE安装一直卡在最后一步解决办法
  • 原文地址:https://www.cnblogs.com/hello-liyb/p/7709642.html
Copyright © 2011-2022 走看看