Struts2 中 web.xml 的翻译

6 篇文章 0 订阅
1 篇文章 0 订阅

 

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值