Struts2 's Valuestack

Source: Internet
Author: User

      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

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.