The role of Strutsprepareandexecutefilter

Source: Internet
Author: User

This article transferred from:

Filterdispatcher is the early struts2 of the filter, the latter are used strutsprepareandexecutefilter, such as 2.1.6, 2.1.8. Strutsprepareandexecutefilter name has been very able to explain the problem, prepare and execute, the former represents the preparation, can be said to refer to the Init method in the filter, that is, the import of the formulation, the latter means that filtering, Refers to the Dofilter method, which requests the request, forwarded to the corresponding action to deal with.

Filterdispatcher is the core filter for struts2.0.x to 2.1.2 version.
Strutsprepareandexecutefilter has been replaced by Filterdispatcher since the 2.1.3 began.

Such a reform is of course of benefit.

Why do you say that.? It should be known that if we define the filter itself, it is to be placed in the STRTUS2 filter before, if placed in the STRUTS2 filter, your own filter action on the action of waste, will not be effective! Unless you are visiting jsp/html!

So I have a need now, I have to use the action environment, and I want to do something with the filter before executing the action, I can't do it with Filterdispatcher.

Then Strutsprepareandexecutefilter can split him into Strutspreparefilter and strutsexecutefilter, and we can add our own filters between the two filters.

To give you a metaphor, now there are patients to do surgery, now struts2 to do two things, take a hospital bed (environment), perform surgery. What about the anesthetic work? It is impossible for a patient to stand and fight, so there must be a hospital bed environment, after the anaesthetic and then operation. This metaphor is very graphic.

If it is a previous version of 2.1.3, use Org.apache.struts2.dispatcher.FilterDispatcher,

Otherwise, use

Starting with Struts2.1.3, the Actioncontextcleanup filter is discarded, and the corresponding function is included in the Strutsprepareandexecutefilter filter.

Three initialization parameters:

1. config parameter: Specifies the configuration file to load. Comma split.

2. Actionpackages parameter: Specifies the package space where the action class resides. Comma split.

3, configproviders parameter: Custom profile provider, need to implement Configurationprovider interface class. Comma split.


If the program class cannot find an exception, and there is behind it

and other information, it may be your version issue. The workaround is to determine your struts version , if it is a previous version of 2.1.3, with Org.apache.struts2.dispatcher.FilterDispatcher, a later version is configured ter

The role of Strutsprepareandexecutefilter

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