Struts1.2 application is still very broad framework, familiar with the basic control process is necessary:
1, ActionServlet initialization
Struts ActionServlet as a component of the front controller, because the corresponding web.xml configuration:
<load-on-startup> 0 </ load-on-startup>
In the application of a load that will be instantiated and call its init method, init method of the work, there are two:
Loaded struts configuration file, and create a package configuration information for the object loaded ModuleConfig resource file, and create resource files for the package MessageResources object needs to pay attention to two things:
If the web.xml multiple module configuration, will create multiple ModuleConfig objects and MessageResources objects were used to encapsulate various modules of the struts configuration file and resource files.
Created for each module and MessageResources ModuleConfig object will be stored in the ServletContext object, the corresponding attribute name in the name of the module corresponding logo.
Also, if the corresponding configuration, then, init method will initialize the data source and PlugIn
<wbr> </ wbr> <wbr> </ wbr>
Second, ActionServlet the process
All of the form *. do requests (in accordance with the relevant web.xml configuration) will be submitted to the ActionServlet, will eventually call its process method. process there are three main methods:
Informed of the requested information, upon request, the module name obtained from the ServletContext and requests the ModuleConfig corresponding object module, and stored in the request.
According to information obtained corresponding module RequestProcessor object, a module corresponds to a RequestProcessor object, RequestProcessor object associated with their corresponding ModuleConfig object module.
Call the process method of RequestProcessor object will request and response as a parameter to it.
3, RequestProcessor's process
RequestProcessor object method of the main work process five steps:
Call your processPreprocess (request, response) method, which does not carry out any operation, for the subclass override to expand its capabilities.
Be matched with the request address ActionMapping object, AcionMapping object used to encapsulate a particular acion configuration information.
According to the configuration information obtained ActionMapping ActionForm object (the object will be cached in the request or session), and fill the form data to the ActionForm, and then decide whether under the ActionMapping configuration verification ActionForm, if verified, will call the validate method of ActionForm If the returned object contains ActionMessage object ActionErros said validation fails, will turn to action directed by the configuration information input property addresses.
If no authentication or verification by ActionForm will create and cache the requested address matches the Action object, the object ActionMapping, ActionForm object, request and response as a parameter called the execute method.
According to Action's execute method returns an object of the ActionForward object, or redirect the request to forward the package to the address of the ActionForward.