Framework learning-ognl expressions in Section 8 of struts2

Source: Internet
Author: User

1. Introduction to ognl

Key points: 1. New functions compared with El expressions

2. Context concept: actioncontext

 

2. actioncontext Structure

Note: 1. After struts2 receives a request, it will quickly create acntioncontext, valuestack, and action and store the action in valuestack. Therefore, the ognl expression can be used to access the instance variable of the action.

2. The standard ognl sets a root object (root object ). Assume that the standard ognl expression is used for evaluation (the ognl expression of struts 2 is not used). If the ognl context (ognlcontext map type) has two objects: Foo object, which is named Foo in the ognlcontext; bar object, which is named bar in ognlcontext. At the same time, the foo object is set as the root object ). Evaluate the value using the following ognl expression:

# Foo. Blah // return Foo. getblah ()

# Bar. Blah // return bar. getblah ()

Blah // return Foo. getblah () Because foo is the root object.

To access objects in the ognl context, you must use the # symbol to mark the namespace, for example, # bar. If the attribute to be accessed belongs to the root object, you can omit the namespace and directly access this attribute.

 

3. Use an ognl expression to obtain the attribute values of each object in the context.

 

The reason why the attribute of the object in valuestack can be obtained using the El expression!

 

The ognl expression must be used together with the struts2 property tag.

 

4. Create list and map set objects using ognl expressions

 

Determines whether an object is in a collection

 

Projection Function

Related Article

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.