Home  >  Struts 2

Struts 2 StrutsPrepareAndExecuteFilter in web.xml

By Arvind Rai, 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
  <display-name>Struts 2 Example</display-name>
In web.xml, we need to define filter and filter mapping. We can provide filter URL pattern on the basis of which URL will be served by StrutsPrepareAndExecuteFilter . In the constructer, init parameter can be passed. In the above filter definition, we are passing action package where all the action classes has been declared. On the basis of given action package, StrutsPrepareAndExecuteFilter filter scans all the action classes.

Download Source Code of Complete Example


©2022 concretepage.com | Privacy Policy | Contact Us