The Struts2 framework uses the Servlet API example, struts2servlet

Source: Internet
Author: User

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()

 

Related Article

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.