Difference between Struts2 FilterDispatcher and StrutsPrepareAndExecuteFilter?
The FilterDispatcher is used in the early Struts2 development, and it has deprecated since Struts 2.1.3.
** UPDATE: Struts 2 Complete tutorial now available here.
If you are using Struts version >= 2.1.3, it’s recommended to upgrade the new filter class StrutsPrepareAndExecuteFilter
The new filter was introduced for the following reasons
- There were a lot of issued with the
FilterDispatcher and its deployment.
- New Filter provides a better way to enable customizations and overrides.
- Make it crystal clear to developers what filters are doing what processes.
- make dispatch process be more flexible to support things like native operation in OSGi or plugin system.
For your reference, the following code should be used when you are about to use Struts version <=2.1.3
1. FilterDispatcher example
The following code should be used when you are about to use Struts version >=2.1.3
2. StrutsPrepareAndExecuteFilter example