Action accesses the api_ of the servlet, with the following main access:
1.> getting the Request object
2.> GET Request Parameters
3.> Gets the response object that can be used to pass cookies
3.> gets the scope object, Request,session,application, and sets the shared data,
Access Method One:
By implementing the Setter method in the perceptual interface, the request parameter in its setter method is passed to this class:
That is, a member variable is defined in this class to receive the request from the setter method.
If you also need to get objects such as response,session,application, then you can only implement Servletresponseaware at the same time,
Applicationaware,sessionaware interface, and implement the setter method in it:
Access Mode II: Servletactioncontext Tool class through struts
The corresponding request and response objects are obtained through the static methods in this class.
Method 3: Pass the Actioncontext tool class
The class is the parent class of Servletacitoncontext, which represents the context object of the action, which indicates that the action exists in the environment
The class object is created through the GetContext () method in the class, and the object is obtained by calling the class method, such as using the GetParameters () method, which returns
A parameter's property name and a map of an array of property values,. When you need to set the request parameter, you add a key-value pair to the resulting map (that is, using the Map.put (Key,value) method;),
To complete the encapsulation settings for the shared request data.
Similarly, for sessions and application, first using Getseesion (), and getapplication (), this method also returns a map collection, as well as the need to set shared parameters,
By adding a key-value pair to the resulting map (that is, using the Map.put (Key,value) method), the encapsulated settings for the shared data can be completed.
Action Access Servlet's API