Struts2 to inject a servlet object into the action

Source: Internet
Author: User
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

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.