Whenever you request a action Then a valuestack push to this statck valuestack What is the structure of it? Is the inclusion of a map stack The structure of
OGNL
before that, you need to know ognl ognl Most of the previous impressions were in the usual jsp page for displaying data similar to el expression or jstl such a label language. In fact ognl java ognl java language. The first work can not use java jsp page to display the data.
Second function: Make the Java language more concise
For example:
such a demand through Person Get Country .
The first scenario: Java Normal Way
Person.getcompany (). Getcountry (). GetName ();
The second method: OGNL An expression
Ognl.get ("Company.country.name", person)
get Value ("Ognl expression object ) company.country.name OGNL expression, and person root object
Valuestack
& nbsp Come back immediately, valuestack OGNL Based on a package, the essence is also used to access data. valuestack The structure is divided into a map context structure, common method is setvalue and findvalue.
Root
1. Stack Structure
2. inherit ArrayList, extend push and pop methods
3. For each action request, the corresponding action object and related objects are pressed into the stack;
Context
1.map structure
2. Why is there a map structure after a root ? Because valuestack is encapsulated based on OGNL , There is only one root object in OGNL. But in general, there is not only one root object, so valuestack to ognl is encapsulated. Enables it to handle data structures of multiple root objects, typically storing objects such as page session application parameter attr .
and the OGNL combine to take a value
1. usually the JSP page is combined with the struts2 tag, and the ognl expression can be used to take the The value in the Valuestack. such as name, this will be in the Valuestack first to find in the context of the findvalue ("name") This method obtains the corresponding value; Map called in Get ("name"). GetName (); get the corresponding value .
Struts2 of Valuestack