Struts controller process

xiaoxiao2021-03-06  118

ActionServlet class

It is the core of the STRUCTS application. It is the primary control component that handles client requests to determine which Action class handles each received request.

ActionServlet class, essence is a simple servlet, and httpservlets are similar, which inherits from the HTTPSERVLET class, and also implements the HTTPSERVLET's lifecycle, init, doget, dopost, destroy.

All specified behaviors originate from the Process () method of the ActionServlet class, which handles all requests.

After the ActionServlet receives the request, follow the steps below:

1) Dopost or doget receives the request and calls the Process method.

2) Process method gets current RequestProcessor, then calls its Process method.

3) The requestProcessor.Process () method is where all requests get true processing. This method finds the element from the struts-config.xml file, and obtains the path of the submitted request. This path is generally specified by the action attribute of tag.

4) If the Process method finds a matching , you will find (where the Name property, and the NAME property of the element are consistent).

5) Process () method Learn to create or get an ActionForm buffer instance after the FormBean is completely named, named by the type property of the element, then fill the value submitted in the request in this instance in.

6) After filling the data, the Process method calls the ActionForm's Validate method to verify the submitted value.

7) At this time, the Process method can start processing the request. It achieves a complete Action class name from the type attribute of element, then create this class, then call the Execute method of this Action subclass.

8) The Action class returns from Processing, the execute method returns an ActionForward object, which is used to determine the target of this transaction. The Process method continues to control and requests will also be forwarded to the determined target.

9) Here, the ActionServlet instance completes the process it handles the request, and is ready to serve future requests.

转载请注明原文地址:https://www.9cbs.com/read-102598.html

New Post(0)