In Method
<Action name = "zilei" class = "dtreeaction" method = "zilei">
<Result name = "listzilei">/zilei. jsp </result>
<Result name = "input">/error. jsp </result>
</Action>
Actioncontext. getcontext (). getvaluestack (). Set ("listzilei", listzilei );
Valid value:
<S: property value = "% {# request. listzilei}"/>
<S: property value = "# request. listzilei"/>
<S: property value = "listzilei"/>
<S: property value = "# ATTR. listzilei"/>
<% = Request. getattribute ("listzilei") %>
$ {Listzilei}
<S: iterator value = "# request. listzilei" id = "dtree">
Can be obtained.
When saved in contextmap:
Actioncontext. getcontext (). getcontextmap (). Put ("listzilei", listzilei );
Value: Use
<S: property value = "listzilei"/> NO
<S: property value = "# session. listzilei"/> NO
<S: property value = "# Params. listzilei"/> NO
Values can be obtained below:
<S: property value = "% {# request. listzilei}"/>
<S: property value = "# request. listzilei"/>
<S: property value = "# ATTR. listzilei"/>
<% = Request. getattribute ("listzilei") %>
$ {Listzilei}
3: directly use request. setattribute ()
Request. setattribute ("listzilei", listzilei );
<S: property value = "% {# request. listzilei}"/>
*
<S: property value = "# request. listzilei"/>
**
<S: property value = "listzilei"/> This is the only option.
***
<S: property value = "# ATTR. listzilei"/>
****
<% = Request. getattribute ("listzilei") %>
*****
$ {Listzilei}
4, maprequest:
Map request1 = (MAP) actioncontext. getcontext (). Get ("request ");
Request1.put ("listzilei", listzilei );
<S: property value = "% {# request. listzilei}"/>
*
<S: property value = "# request. listzilei"/>
**
<S: property value = "listzilei"/> NO
***
<S: property value = "# ATTR. listzilei"/>
****
<% = Request. getattribute ("listzilei") %>
*****
$ {Listzilei}
******
Summary:The value range of getcontextmap is greater than that of valuestack. Only saved in the attribute of the request. Contextmap is the same as manual request. setatribute () and MAP request.
Struts2, a page url to pass the value, and then execute the method, then to B page, A. jsp? Id = 33. values can be obtained on the B. jsp page.
Use
<Action name = "delete1" class = "dtreeaction" method = "delete1">
<Result type = "Redirect-action" name = "success">
<Param name = "actionname"> zilei1.action </param>
<Param name = "ID" >$ {ID} </param>
</Result>
</Action>
<S: property value = "% {# request. ID}"/>
*
<S: property value = "# request. ID"/>
**
<S: property value = "ID"/> NO
***
<S: property value = "# ATTR. ID"/>
****
<% = Request. getattribute ("ID") %>
*****
$ {ID}
Click Delete on page B and return to page B. There is nothing.
When $ {ID} is used in struts. xml:
// Request. setattribute ("ID", ID); No
// Actioncontext. getcontext (). getvaluestack (). Set ("ID", ID); yes
// Actioncontext is the ognl context, which is the largest context. E
// Actioncontext. getcontext (). getcontextmap (). Put ("ID", ID); yes
// Request1.put ("ID", ID); No
When $ {request. ID} is used in struts. xml:
Request. setattribute ("ID", ID); yes
Actioncontext. getcontext (). getvaluestack (). Set ("ID", ID); yes
Actioncontext is the ognl context, which is the largest context. E
Actioncontext. getcontext (). getcontextmap (). Put ("ID", ID); yes
Request1.put ("ID", ID); yes
Yes.
Conclusion: contextmap can obtain values in the Struts. xml file. The value cannot be obtained using valuestack.
The ognlvaluestack class contains two important attributes: Root and context. Root is essentially an arraylist, while context is a map (more specifically an ognlcontext object ).
That is to say: the map has a larger range, so it cannot be obtained. A vertical string is of the map type.
The main attribute relationship diagram of the ognlvaluestack class is as follows:
|
| -- Application
|
| -- Session
Context map (ognlvaluestack attribute) -- |
| -- Value stack (root attribute of ognlvaluestack, which is actually an arraylist)
|
| -- Request
|
| -- Parameters
|
| -- ATTR (searches page, request, session, then application scopes)
Ognlvaluestack is the foundation of actioncontext
Currently, we can use contextmap and valuestack as the same, but they are different in the. xml file.