Master filter for Struts that handles four distinct responsibilities:
- Executing actions
- Cleaning up the {@link ActionContext} (see note)
- Serving static content
- Kicking off XWork's interceptor chain for the request lifecycle
IMPORTANT: this filter must be mapped to all requests. Unless you know exactly what you are doing, always map to this URL pattern: /
Executing actions This filter executes actions by consulting the {@link ActionMapper} and determining if the requested URL shouldinvoke an action. If the mapper indicates it should,
the rest of the filter chain is stopped and the action is invoked. This is important, as it means that filters like the SiteMesh filter must be placed
before this filter or they will not be able to decorate the output of actions.
Cleaning up the {@link ActionContext} This filter will also automatically clean up the {@link ActionContext} for you, ensuring that no memory leakstake place. However, this can sometimes cause problems integrating with other products like SiteMesh. See {@link ActionContextCleanUp} for more information on how to deal with this.
Serving static content This filter also serves common static content needed when using various parts of Struts, such as JavaScript files, CSS files, etc. It works by looking for requests to /struts/*, and then mapping the value after "/struts/" to common packages in Struts and, optionally, in your class path. By default, the following packages are automatically searched:
- org.apache.struts2.static
- template
This means that you can simply request /struts/xhtml/styles.css and the XHTML UI theme's default stylesheet will be returned. Likewise, many of the AJAX UI components require various JavaScript files, which are found in the org.apache.struts2.static package. If you wish to add additional packages to be searched, you can add a comma separated (space, tab and new line will do as well) list in the filter init parameter named "packages".
Be careful, however, to expose any packages that may have sensitive information, such as properties file with database access credentials.
This filter supports the following init-params:
- config - a comma-delimited list of XML configuration files to load.
- actionPackages - a comma-delimited list of Java packages to scan for Actions.
- configProviders - a comma-delimited list of Java classes that implement the {@link ConfigurationProvider} interface that should be used for building the {@link Configuration}.
- loggerFactory - The class name of the {@link LoggerFactory} implementation.
- * - any other parameters are treated as framework constants.
To use a custom {@link Dispatcher}, the
createDispatcher()
method could be overriden by the subclass.
@version $Date$ $Id$
@deprecated Since Struts 2.1.3, use {@link org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter} instead or{@link org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter} and {@link org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter}if needing using the {@link ActionContextCleanUp} filter in addition to this one
@see ActionMapper
@see ActionContextCleanUp
@see org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
@see org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
@see org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter