In the STRUTS2 framework, you can inject a Servlet object into an action by IOC, and you typically need the action to implement the following interfaces:
A. Servletrequestaware:
The action that implements the interface can directly access the request object, which provides void Setservletrequest (HttpServletRequest request)
Method that implements the action control class for this interface to inject the request object into the action through the Setservletrequesthttpservlet (HttpServlet request) method.
B. Servletresponseaware:
The action class can directly access the response object by implementing the Servletresponseaware interface, similar to the Servletrequestaware interface by providing a void Setservletresponse (HttpServlet resonse) injects the response object into the action so that it can be used directly.
C. Sessionaware:
The action that implements the interface can directly access the session object, which provides a void setsession (map map) method, with the same injection principle as the request and response principles. The session object is injected into the action by implementing the Set method of the corresponding interface.
Struts2 to inject a servlet object into the action