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!