您的位置:首页 > 其它

ESX常见的文件类型

2013-02-26 15:32 134 查看
The primary feature of JSP 2.0 is its support for an expression language(EL). An expression language makes it possible to easily access application data stored in javabeans components.
 
Active and Deactive EL:
<%@page isELIgnored=”false | true”%>
 
 
EL可以被用在哪里?
l         静态文本
${“static text……”}
 
l         In any standard or custom tag attribute that can accept an expression
<some:tag value=”abc ${a1} ${a2}” />
 
 
 .   和  []  访问对象的属性
${user.id} 与 ${user[‘id’]} 效果是一样的,都是调用getId()方法。这里注意,访问的是属性property而非字段field,所以,user并不一定要有名为id的字段,但一定要有名为getId()的方法用以供调用。
如果user是一个javabean,那么用.和[]就是去调用其property的访问方法。
如果user是一个List, 那么id就会被强制转成int,然后实行user.get(id),从而返回了List中的元素。若产生IndexOutOfBoundsException,将返回null,若是别的异常,将被抛出。
      如果user是一个Map,那么id被当作key,然后执行user.get(id),返回key所对应的值。若 user.containsKey(id)为false,则返回null.
 
 
EL除了可以从不同的访问范围内拿我们设定的对象,还可以访问隐性对象 Implicit Object. 隐性对象是指,由web container在application加载的时候而设定的。JSP定义了一些列Implicit Object,如:
pageContext

   -servletContext

   -session

   -request

      -
response

等等。我们可以使用EL来直接访问,${pageContext.request.localName}
${pageContext.session.creationTime}
 
 
 
 
 
 
Table 12-2 Example Expressions 
EL Expression
Result
${1 > (4/2)}
false
${4.0 >= 3}
true
${100.0 == 100}
true
${(10*10) ne 100}
false
${'a' < 'b'}
true
${'hip' gt 'hit'}
false
${4 > 3}
true
${1.2E4 + 1.4}
12001.4
${3 div 4}
0.75
${10 mod 4}
2
${empty param.Add}
True if the request parameter named Add is null or an empty string
${pageContext.request.contextPath}
The context path
${sessionScope.cart.numberOfItems}
The value of the numberOfItems property of the session-scoped attribute named cart
${param['mycom.productId']}
The value of the request parameter named mycom.productId
${header["host"]}
The host
${departments[deptName]}
The value of the entry named deptName in the departments map
${requestScope['javax.servlet.
forward.servlet_path']}
The value of the request-scoped attribute named javax.servlet.
forward.servlet_path
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: