Difference between strutsprepareandexecutefilter and filterdispatcher

Source: Internet
Author: User

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 .!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.