el表達式

1.el表達式寫法示例:

直接在jsp頁面中寫:${empty message.btykjzzszyfpyy }  其中empty是運算符,message是request中的對象,btykjzzszyfpyy 是message的屬性。

 

2.el表達式

    This documentdescribes an expression language (EL) for JSP. This expression language has twoversions: one applicable to the JSP Standard Tag Library (JSTL), the other applicableto JSP 1.3. Both expert groups have collaborated to design the expression language,but their schedules are different, and the requirements vary somewhat too.

    This documentdescribes the expression language for JSTL 1.0. Ideally, this version of the expressionlanguage will be compatible with that used in JSP 1.3, but we can't rule out that theremay be changes that are deemed necessary by the expert groups. If that turns out tobe the case, we will incorporate those changes into a maintenance

release of JSTL.

     The EL is inspired by both ECMAScriptand the XPath expression languages。

     In JSTL, the EL isavailable only in attribute values (in JSP 1.3, the EL can also be used within template text).The EL is invoked exclusively via the construct ${expr}.

The EL evaluates anidentifier by looking up its value as an attribute, according to the behavior ofPageContext.findAttribute(String). For example:

     ${product}

      This expressionwill look for the attribute named "product", searching the page, request, session,and application scopes, and will return its value. If the attribute is

not found, null isreturned.

3.el表達式隱式對象

    The EL defines aset of implicit objects. When an expression references one of these objects by name, theappropriate object is returned instead of the corresponding

attribute. Forexample:

    ${pageContext}

    returns thePageContext object, even if there is an existing pageContext attribute containing someother value.

    The followingimplicit objects are available:

     pageContext - thePageContext object

     pageScope - a Mapthat maps page-scoped attribute names to their values

     requestScope - aMap that maps request-scoped attribute names to their values

     sessionScope - aMap that maps session-scoped attribute names to their values

     applicationScope -a Map that maps application-scoped attribute names to their values

     param - a Map thatmaps parameter names to a single String parameter value (obtained by callingServletRequest.getParameter(String name))

     paramValues - a Map that maps parameter namesto a String[] of all values for that parameter(obtained by calling ServletRequest.getParameterValues(Stringname))

     header - a Mapthat maps header names to a single String header value (obtained by callingServletRequest.getHeader(String name))

     headerValues - aMap that maps header names to a String[] of all values for that header(obtained by calling ServletRequest.getHeaders(String))

     cookie - a Mapthat maps cookie names to a single Cookie object. Cookies are retrieved accordingto the semantics of HttpServletRequest.getCookies(). If the same name isshared by multiple cookies, an implementation must use the first oneencountered in the array of Cookie objects returned by the getCookies() method.However, users of the cookie implicit object must be aware that theordering of cookies is currently unspecified in the Servlet specification.

    initParam - a Mapthat maps context initialization parameter names to their String parametervalue (obtained by calling ServletContext.getInitParameter(Stringname))


4.el表達式語法:

    The syntax is quitesimple. Variables are accessed by name. A generalized [] operator can be used toaccess maps, lists, arrays of objects and properties of a JavaBeans object; the operatorcan be nested arbitrarily. The "." operator can be used as a convenient shorthandfor property access when the property name follows the conventions of javaidentifiers, but the [] operator allows for more generalized access.

    Relationalcomparisons are allowed using the standard Java relational operators. Comparisons may bemade against other values, or against boolean (for equality comparisons only),String, integer, or floating point literals. Arithmetic operators can be used tocompute integer and floating point vlaues. Logical operators are available.

 

5.el表達式強制類型轉換

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章