OGNL and ValueStack, OGNLValueStack

Source: Internet
Author: User

OGNL and ValueStack, OGNLValueStack
Introduction to OGNL

   

The full name of OGNL is Object Graph Navigation Language, which is the Language of the Object Navigation chart. It is an open-source project that works on the view layer. It reads the attribute values of the appropriate Java object through a simple and consistent expression language, calls the object method, and traverses the structure of the entire object, converts the field type.

Introduction to OGNL
   

OGNL computing is based on OGNL context. The OGNL context is actually a Map set, represented by the ognl. OgnlContext class (which is encapsulated into ActionContext ). It can contain one or more context objects.

First, let's take an example to introduce the use of OGNL expressions.

Common Action Code:

The action configuration information is omitted...

View page code:

   

Through the above example, we found that in the Action class, we use two methods to assign values to ValueStack, And the syntax for reading the view page is different, but why? This is about ValueStack.

ValueStack
   

ValueStack is also a value stack. Simply put, a value stack is a storage area created by the Framework to save Model objects. It has the stack feature and can store multiple objects.

You can also use the <s: debug> </s: debug> label on the view page to view information in the value stack ,:

   

We can see that the ValueStack displayed on the page is roughly divided into two areas: Value Stack Contents and Stack Context. Value Stack Contents is the Root object and stores data in the form of ArrayList. The OGNL expression language can directly obtain the corresponding value through the Property Name. The data in Stack Context is stored in Context, which stores data in the form of map sets. When using an OGNL expression for access, you must add "#" as the prefix.

Other Objects in ActionContext are not described here. They can be operated using OGNL expressions. However, except for the value in the Root object, "#" must be added as the prefix for accessing other values!

 

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.