user663724
user663724

Reputation:

Confusion with web.xml file for Struts2

I am trying to learn Struts2. When I see the web.xml file for Struts2 in some of the sites it's mentioned as:

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

and where as in some examples its mentioned as:

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

Could anybody please help me? What is correct and why is it there are two approaches?

Thank you very much.

Upvotes: 1

Views: 523

Answers (2)

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

Basically StrutsPrepareAndExecuteFilter been introduced due to variety of reasons

  1. older filter setup was confusing and led to issues
  2. The new setup also was forward looking towards the OSGi plugin.
  3. Better enable customizations and overrides by advanced users

for further information follow the below mentioned thread

New filter strategy RFC Struts2

Upvotes: 2

Victor Martinez
Victor Martinez

Reputation: 1112

The FilterDispatcher (org.apache.struts2.dispatcher.FilterDispatcher) it’s deprecated since Struts 2.1.3. It’s always recommend to use StrutsPrepareAndExecuteFilter

Upvotes: 5

Related Questions