EL--2

来源:互联网 发布:数据库设计的最后阶段 编辑:程序博客网 时间:2024/06/18 08:26

  JSP  EL运算符

 

类型:                       

 

算术型:

           +、-、*、/、div、 %、mod

逻辑型:

           and、&&、or、||、!、not

关系型:

           ==、eq、!=、ne、>、gt、<=、le、>=、ge、lt、<

条件型:

           a?b:c

空:

           empty

 


JSP  EL的基本用法:

  类型:                     示例:                               对应的调用方法:

javaBeans         ${user.username}                           user.getUsername()

                          ${user["username"]}

                          ${user['username']}                                                    

 

数组:                    ${sport["1"]}                        sport[1]

                          ${sport[1]}

                          ${sport['1']}

 

List:                      ${address["2"]}                      phone.get(2)

                           ${address[2]}

                           ${address['2']}

Map:                        ${phone['office']}                  phone.get("home")

                            ${phone["office"]}

                            ${sport.office}                

在编写过程中应统一

 

 

JSP EL的内置对象:  El的内置对象 与 JSP中的内置对象 不相同  EL的内置对象不能用在jsp中 只能用在EL表达式中

 

pageContext

pageScope

requestScope

sessionScope

applicationScope

param

paramValues

header

headerValues

Cookie

initParam

例子:<%= session.getAttribute("phone")%>
       等价于:${sessionScope.phone}

设定JSP不使用JSP EL   现在的技术很多,在开发中可能有些技术与EL相冲突
 
  使用page指令的isELIgnored属性
          <%@page isELIgnored=“true”%>
  或者修改web.XML
     <web-app ……>
      <jsp-config>
        <jsp-property-group>
           <url-pattern>*.jsp </url-pattern>
           <el-ignored>true</el-ignored>
        </jsp-property-group>
      </jsp-config>
     </web-app>

    

实例JSP  EL的用法

原创粉丝点击