ValueStack and OGNL are used to store Struts2 form data. valuestackstruts2

Source: Internet
Author: User

ValueStack and OGNL are used to store Struts2 form data. valuestackstruts2


(1) I recently learned the struts framework. We are pleased with the strength of struts, which facilitates the use of the forwarder, but do not know the specific storage of internal data;


(2) I found a lot about the principles of struts data storage on the Internet, but I have not found a detailed explanation. I occasionally found it in a book.

This topic describes how ValueStack and OGNL store Struts2 form data!


(3) The following section describes how to store data forms in the struts framework!








I think this book is really good! You need to reply to the fuel tank address!





In struts2, what is the sequence of objects in valuestack going to stack? For more information,

First, let's take a look at ognl.
Ognl expressions are not implemented based on struts2 and are used in common java projects. you only need to create an ognlContext. The source code shows that the object implements the map interface, which is actually an encapsulation of the map structure. you can put () into object reference.
Use ognl: Create an ognlContext object ognl, and then set the object you need to use setRoot (reference name) to a root object. You can get it through the getValue () method.
I recommend you an article blog.csdn.net/it_man/article/details/6000655
In struts, OGNLContext is actually ActionContext, and all objects maintained in it can be obtained according to the OGNL expression, while ROOT is VALUEStack, which is the stack object and implements the ARRAYList interface. the top of the stack is an object of the Action you are using. actually, OGNL expressions
Eg: "Object Name" = "(StackValue) ActionContext. getcontext (). getStackValue (). peek (). get attribute name"
Other objects, such as sessions, are also in ActionContext, but they are not root, so the methods for obtaining them are different.
Session: ActionContext. getcontext (). getSession. get attribute name.

The framework sets the OGNL context to be our ActionContext, and the value stack to be the OGNL root object. (The value stack is a set of several objects, but to OGNL it appears to be a single object .) along with the value stack, the framework places other objects in the ActionContext, including Maps representing the application, session, and request contexts. these objects coexist in the ActionContext, alongside the value stack (our OGNL root ).

Let's talk about it:
The Struts2 framework sets the Context of OGNL as ActionContext, and the Value Stack is the root object of OGNL. (Although Value Stack is a collection of multiple objects, Value Stack is a single object for OGNL ). In addition to Value Stack, the Struts2 framework also places other objects in the ActionContext. These objects include maps corresponding to applications, sessions, and requests. These objects and Value Stack (Our OGNL root object) constitute ActionContext.

In the STACK order, there is no doubt that the instance object of action is the last because it is placed at the top... the rest of the full text>

If the Struts2 tag is not used for data transmission in struts2, is ValueStack still used?

VS is something of struts2. Of course it cannot be used elsewhere. Only the struts2 tag can be recognized.
There are detailed information about struts2 on the network. You can search every part of struts2.
The data transmission format is generally json. Json is like an array. It contains a piece of data, but each piece of data is in the form of K/V, separated by commas (,).

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.