Current location - Recipe Complete Network - Food world - How does struts2.0 work?
How does struts2.0 work?
The client sends a request, and the server-side StrutsPreparedAndExceuteFilter receives the request.

If the request is made with. During operation, Struts2 will forward the request to the corresponding data type conversion operation, and if there is an error in data type conversion, it will return to the result page specified by input.

If there is no error in data type conversion, the setXX method is called to set the value, and if the validate () method is used (or the validation framework is used), the corresponding validation is performed.

If there is an error in the verification, return to the page where the specified result is entered.

If validation is not used or there are no errors in validation, execute () method and return to the corresponding page.

Extended data:

Struts2 process notes

When the Web container receives a request (HttpServletRequest), it passes the request to the standard filter chain containing the ActionContextCleanUp filter.

After other filters (SiteMesh, etc.), you need to call the FilterDispatcher core controller, and then it calls ActionMapper to determine which operation to request, and ActionMapper returns an ActionMaping object that collects operation details.

The FilterDispatcher delegates the ActionProxy, which calls the ConfigurationManager to read the configuration information (struts.xml) from the configuration file, and then creates the ActionInvocation object.

ActionInvocation will call the used configuration interceptor (interceptor n) in turn before calling Action. Once the execution Result returns the result string, ActionInvocation is responsible for finding the corresponding result string, and then executing this result result will call some templates (JSPs) to render the page.

Interceptor n will be executed again (in the reverse order of the previous operations), and the final response (HttpServletResponse) will be returned to the filter and FilterDispatcher configured in web.xml.

Baidu encyclopedia -Struts 2