The web.xml web application descriptor描述符号 file represents the core of the Java web application, so it is appropriate适当的 that it is also part of the core of the Struts framework. In the web.xml file, Struts defines its FilterDispatcher, the Servlet Filter class that initializes the Struts framework and handles操纵 all requests. This filter can contain initialization parameters that affect what, if any, additional附加的 configuration files are loaded and how the framework should behave.
In addition添加 to the FilterDispatcher, Struts also provides an ActionContextCleanUp class that handles special特别的 cleanup tasks任务 when other filters, such as those used by Sitemesh, need access to an initialized Struts framework.
Key Initialization Parameters
- 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 ConfigurationProvider interface that should be used for building the Configuration.
- loggerFactory - The class name of the LoggerFactory implementation.
- * - any other parameters are treated as framework constants常量.
Why the Filter is mapped with /* and how to configure explicit明确的 exclusions除外。。 (since 2.1.7) In the example above we've mapped the Struts 2 dispatcher to /*, so Struts 2 has a crack裂缝 at all incoming进来的 requests. This is because Struts 2 serves static content from its jar files, including Dojo JavaScript files (if using S2.0, or the Dojo plugin in S2.1+) and FreeMarker templates模板 for the Struts 2 tags标签 that produce HTML. If we change the filter mapping to something else, for example /*.html, we must take获得 this in to account and extract提取 the content that would normally正常的 be served from the Struts 2 jar files, or some other solution解决方案. Since Struts 2.1.7, you are able to provide a comma逗号 seperated分离 list of patterns模式 for which when matching against the <struts> <constant name="struts.action.excludePattern" value=".*unfiltered.*,.*\\.nofilter"/> ... </struts> |