zoukankan      html  css  js  c++  java
  • EL表达式


    EL表达式

             1、作用:
                主要是用来获取作用域中的数据的,使用的时候不需要导包,获取的时候不需要强转
    获取用户数据
    <%=request.getParameter("uname")%>  
    ${param.uname}  

    localhost:8080/EL/el.jsp?fav=0&fav=1&fav=2
    ${paramValues.fav[0]}  
    获取作用域中的数据

    <%=request.getAttribute("s")%>
      
    ${s}  

    <%=((User)request.getAttribute("u")).getAddr().getTown()%>
    ${u.addr.town}  

    获取集合中的数据

    <%=((ArrayList)request.getAttribute("list")).get(2) %>
    ${list[2]}

    <%=((User)((ArrayList)request.getAttribute("list")).get(3)).getAddr().getTown()%>  
    ${list[3].addr.town}

    <%=((HashMap)request.getAttribute("hs")).get("a3")%>  
    ${hs.a3}  或  ${hs["a3"]}

    <%=((User)((HashMap)request.getAttribute("hs")).get("u")).getAddr().getTown()%>  
    ${hs.u.addr.town}

      

            
            2、语法:
                $+{}
                获取用户数据:$+{param.键名}  $+{paramValues.键名}
                获取作用域中的数据:$+{键名}
                获取作用域中集合数据:
                            list:$+{键名[角标].属性}
                            map:$+{键名.key.属性}
     
            3、使用:不能获取普通变量的值
                作用的查找顺序:
                    pageContext--request---session---application:从小到大依次查找,找到了就不再找了,如果四个作用域中都没有对应的值,则什么都不显示,并不会报错
                      指定作用域查找:${域名Scope.键名}
                      ${pageScope.h}---${requestScope.h}--${sessionScope.h}--${applicationScope.h}  
     
                  EL表达式的逻辑运算:
                    ${1+2}--${1==1}--${2>1}--${1+"3"}--${1==1?"男":"女"}
     
                  关键字empty:(判断是否有s2键对应的值)
                    ${empty s2} 
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    MBR:How It Works Master Boot Record
    查看系统信息命令:uname
    随笔:Highcharts学习笔记
    关于邮箱模板样式设计的一些思考
    Android学习笔记之环境搭建
    [转]简要分析Ogre渲染队列的实现原理(一)
    [转]Improving link time with IncrediBuild,减少联合编译器的链接是时间
    [转]目前游戏行业内部主要几款游戏引擎的技术对比
    [转]行程编码(Run Length Encoding)和算术编码
    [转]简要分析Ogre的渲染队列实现原理(二)
  • 原文地址:https://www.cnblogs.com/haozhengfei/p/6537822.html
Copyright © 2011-2022 走看看