El-Expressions and Ognl expressions

Source: Internet
Author: User

El (Expression language)

El base Operator

El can suppress objects (that is, they can be accessed directly)

El is used in two ways, the second seems to be useless in JSP, mainly used in JSF

El can access the object (JavaBean, class set, enumeration, implied object)

Some of the things that I think are useful on Oracle's official website:

1.
${customer}
The Web container evaluates the variable that appears in a expression by looking the IT value according to the behavior O F Pagecontext.findattribute (String), where the String argument is the name of the variable. For example, when evaluating the expression ${customer}, the container would look for customer in the page, request, SE Ssion, and application scopes and would return its value. If customer is not found, a null value is returned.

The Web container is using the Pagecontext.findattribute (String) method in the background to process this code, which is defined as follows:

The method is abstract class PageContext inherits the abstract class Jspcontext.

The definition of this method is basically the same as the description of the red font above, which means that the customer property is searched in this order, application, page, request--, and if there is a return, no returns NULL.

2.

Where Value Expressions Can be used
Value expressions using the ${} delimiters can be used in

Static text

Any standard or custom tag attribute the can accept an expression

The value of an expression in a static text is computed and inserted to the current output. Here's an example of a expression embedded in static text:

<some:tag>
Some text ${expr} some text
</some:tag>
If the static text appears in a tag body, note this an expression would not be evaluated if the body was declared to be TAGD Ependent.

Lvalue expressions can is used only in tag attributes that can accept Lvalue expressions.

A tag attribute value using either an rvalue or lvalue expression can is set in the following ways:

With a single expression construct:

<some:tag value= "${expr}"/>
<another:tag value= "#{expr}"/>
These expressions is evaluated, and the result was converted to the attribute ' s expected type.

With one or more expressions separated or surrounded by text:

<some:tag value= "some${expr}${expr}text${expr}"/>
<another:tag value= "some#{expr}#{expr}text#{expr}"/>
These kinds of expression, called composite expressions, is evaluated from left to right. Each expression embedded in the composite expression was converted to a String and then concatenated with any intervening t Ext. The resulting String is then converted to the attribute ' s expected type.

Just look at the color of the word, the first said El can be normal text and the value of the label to use, the second and third color words are in ordinary text and as a label attribute instance. The fourth indicates that El can be used in conjunction with any text, where the # I do not know what to use in JSP.

Ognl

1. The Object-graph Navigation Language (OGNL) is a powerful expression Language this is used to reference and MA Nipulate data on the valuestack. OGNL also helps in data transfer and type conversion.

The OGNL is very similar to the JSP Expression Language. OGNL is based on the have a root or default object within the context. The properties of the default or root object can be referenced using the markup notation, which is the pound symbol.

This is the definition of OGNL in the extract http://www.tutorialspoint.com/, presumably to say that OGNL is primarily used to manipulate the contents of the value stack and to perform data conversion and type conversions, as described in the site for value stack:

There are two cases of using the OGNL to manipulate the value stack

El-Expressions and Ognl expressions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.