Struts 2 StrutsPrepareAndExecuteFilter in web.xml
April 30, 2014
StrutsPrepareAndExecuteFilter belongs to org.apache.struts2.dispatcher.ng.filter package. StrutsPrepareAndExecuteFilter can also be understood by its name. StrutsPrepareAndExecuteFilter has the responsibility to prepare and execute all phases of struts. The question is when we should use StrutsPrepareAndExecuteFilter filter. Struts 2 apache documentation says that when there is no other filter being used that can access action context information, better to use StrutsPrepareAndExecuteFilter filter. Now we will see how to use this filter in web.xml
web.xml
<web-app> <display-name>Struts 2 Example</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>actionPackages</param-name> <param-value>com.concretepage.action</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>