struts2 Principle of framework operation process



struts2 Principle of framework operation process

Don't say anything , First map ~
struts2 Picture description of framework operation process principle



First step : To determine whether or not struts2 management

Request come , First through the filter ( hereinafter referred to as ), Confirm whether it is necessary after internal method judgment struts2 Frame to handle ( The method is used to determine whether the request needs struts2 Handle , if necessary , So why take over , Through configuration management, we can find our struts.xml, And then into the real thing Action);


The second step : Get core profile information

Enter the dynamic agent , Read the core configuration file by , The purpose is to get what the request needs from the core configuration file action Method configuration information ( For example, whether there is this action、action Access path and other information );


The third step : Request related action Give the information to the interceptor team

The relevant information found in the core configuration file is fed back to the dynamic proxy object , The dynamic proxy object passes this information to ;


Step four : It's filtered by the interceptor to get String Result of type

It's a collection of interceptors , There is a default in this 20 An interceptor , You can see it in the file , As shown in the figure below :
 Set picture description of interceptor
After a series of interceptor filters , To obtain a String Result of type ( This string The result of type is that we are action Class , Generally, we are set to ;


Step five : according to String The return result of type matches that in the core configuration file

Give the result return value to the configuration tag in the core configuration file , There is a tag in the configuration tag , The name of the return value obtained should be the same as that in the label name Value consistent , Then call the specified method in the label or jump to the corresponding page ;
 Return the result picture description


Step six : Again, the interceptor returns the final result to the customer

After filtering by layer by layer interceptors from the inside out, the returned results will be responded to the customer ;


This is it. Struts2 The working principle and process of ~


《END》