Using the Servlet API step in Struts2

Source: Internet
Author: User

Using the Servlet API step in Struts2

Objects such as request are declared in the action class

Map<string, object> request;

Get Actioncontext instances

Actioncontext Ac=actioncontext.getcontext ();

Get objects such as request

Request= (map<string, object>) ac.get ("request");

Saving data in objects such as request

Request.put ("loginaccess", "Login Location: Beijing");

Request.get ("loginaccess");

Get the way to save data in the page

<s:property value= "#request. Loginaccess"/> Access servlet API

Other ways to access the servlet API

Previous ways to get Servlet API objects

Get Request:ac.get Yourself ("request")

Structs2=structs1 's popularity and market +webwork techniques convert a string to a OGRL expression%{}

Get Session:ac.getSession Yourself ()

Let "someone else" provide you with the Servlet API object

Get the Servlet API object by implementing the appropriate interface

Obtaining the request requires implementing the Requestaware interface

Getting the session requires implementing the Sessionaware interface

Get application need to implement Applicationaware interface

Using the Servlet API step in Struts2

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.