Strut2 OGNL Remove the value stored in the Request,session,application and the object stack

Source: Internet
Author: User

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

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.