Transfer http://wellfrog.iteye.com/blog/773482
Filterdispatcher is the filter of the early struts2, and later uses strutsprepareandexecutefilter, such as 2.1.6 and 2.1.8. The strutsprepareandexecutefilter name is already very descriptive. prepare and execute indicate preparation. The former indicates the init method in the filter, that is, the preparation import. The latter indicates filtering and the dofilter method, forward the request to the corresponding action for processing.
Filterdispatcher is the core filter of struts2.0.x to 2.1.2 .!
Strutsprepareandexecutefilter replaces filterdispatcher since 2.1.3 .!
This reform is of course beneficial .!
Why .? We should know that if we define our own filter, it should be placed before the strtus2 filter. If it is placed after the struts2 filter, your own filter will be useless for Action filtering and will not be effective! Unless you access JSP/html!
Now I have a requirement. I must use the action environment and want to use the filter to do something before executing the action. I cannot use filterdispatcher .!
Then, the strutsprepareandexecutefilter can be split into strutspreparefilter and strutsexecutefilter. Our own filters can be added between these two filters .!
Let me give you a metaphor. Now there is a patient who wants to perform an operation. Now struts2 has to do two things: Build a bed (Environment) and perform the operation .! What about the anesthetic work .? It is impossible for the patient to stand and fight, so the hospital bed must be in the environment and the anesthetic should be operated .! This metaphor is very vivid .!