1. Remove the value from the Request,session,applicaiton
A. Add a value to add request,session,application to the inside
Public String Testservlet () {servletactioncontext.getrequest (). SetAttribute ("Request_username", "username"); Actioncontext.getcontext (). GetSession (). Put ("Session_username", "username"); Servletactioncontext.getservletcontext (). SetAttribute ("Application_username", "username"); return "servlet";}
Value:
Output the value in the Request,session,application field, because the access is a map, so add a # <br> request value: <s:property value= "# Request.request_username "/><br> Session Value: <s:property value=" #session. Session_username "/> <br> Application value: <s:property value= "#application. Application_username"/><br>
2. Using the Set method of the object stack in Valuestack to store the data, encapsulate the object into a hashmap, put it into the top of the stack
A. Put value
Public String Testvaluestack_set () {Valuestack valuestack = Actioncontext.getcontext (). Getvaluestack (); Valuestack.set ("msg", "message"); return "Value_stack_set";}
B. Take value
Output Valuestack The Set method of the data stored, the actual output is the stack top data <br> <s:property value= "MSG"/><br>
3. in both Person,student and ognlaction, the test page will output the first commit in the stack, which is the commit in Ognlaction
A. Put values, use the Add method to place
Public String Testvaluestack_deep () {person person=new person ();p erson.setage (New Integer (1));p erson.setname (' person ");p erson.setcommit (" person "); Student student=new Student () student.setage (2); Student.setname ("Student"); Student.setcommit ("Student"); Valuestack valuestack = Actioncontext.getcontext (). Getvaluestack (); Compoundroot root = Valuestack.getroot (); Root.add (person); Root.add (student); return "Valuestack_deep";}
Value:
In both Person,student and ognlaction, the test page will output the first commit in the stack, which is the commit <s:property value= "commit" in ognlaction. />
Strut2 OGNL Remove the values stored in the Request,session,application and the object stack