The Struts2 framework uses the Servlet API example, struts2servlet
1. Some common Servlet APIs can also be obtained in the Action class.
* Requirement: provide the data on the JSP form page, which is received by using the Servlet API in the Action, saved to three domain objects, and finally displayed on the JSP page.
* The JSP registration page is provided to demonstrate the following three methods:
<H3> registration page
2. completely decoupled Mode
* If this method is used, the Struts2 framework provides an ActionContext class that provides some methods to obtain the Servlet API
* Some common methods are as follows:
Static ActionContext getContext () -- get the ActionContext object instance java. util. map <java. lang. string, java. lang. object> getParameters () -- GET request parameters, which is equivalent to request. getParameterMap (); ava. util. map <java. lang. string, java. lang. object> getSession () -- obtains the Map set representing the session domain, which is equivalent to operating the session domain. Java. util. map <java. lang. string, java. lang. object> getApplication () -- Obtain the void put (java. lang. string key, java. lang. object value) -- Note: The value is saved to the request domain.
3. Use native Servlet APIs
* The Struts2 framework provides a class, ServletActionContext, which provides some static methods.
* The specific method is as follows:
getPageContext()getRequest()getResponse()
getServletContext()