Struts2 中 web.xml 的翻译

 

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(由一个基于Web页面布局、装饰以及与现存Web应用整合的框架), 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框架。主要由三大模块组成:Core、Dijit、DojoXJavaScript files (if using S2.0, or the Dojo plugin in S2.1+) and FreeMarker(一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写) 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

request URL the Filter will just pass by. This is done via the configuration option struts.action.excludePattern, for example in your struts.xml.

 

<struts>
    <constant name="struts.action.excludePattern" value=".*unfiltered.*,.*\\.nofilter"/>
    ...

</struts>

你可能感兴趣的:(Web,xml,struts2,翻译)