web.xml

来源:互联网 发布:js array 方法大全 编辑:程序博客网 时间:2024/06/15 19:29

The web.xml web application descriptor(描述) filerepresents(代表) the core of the Java web application, so it isappropriate(适当的) that it is also part of the core of the Struts framework. In the web.xml file, Strutsdefines(定义) its FilterDispatcher, the Servlet Filter class thatinitializes(初始化) the Struts framework andhandles(处理) all requests. This filter cancontain(包含) initialization parameters that affect what, if any, additional configuration files are loaded and how the framework should behave.

web.xml 描述了代表Java web应用程序的核心。所以它是struts框架的的核心部分,

在这web.xml文件中,Struts定义了它的FilterDispather,servletFilter类初始化了Struts框架和处理了所有的request

fiter能设置初始参数的作用,其他配置文件被加载和框架如何表现。

In addition to the FilterDispatcher, Struts also provides an ActionContextCleanUp class thathandles(处理) special cleanup tasks(任务) when other filters, such as those used by Sitemesh, need access to an initialized Struts framework.

加入FilterDispatcher,Struts同样提供了一个ActionContextCleanUp类,它处理清楚任务,

例如那些被使用通过Sitemesh,需要访问一个初始化Struts框架.


Key Initialization Parameters //初始化参数值

  • config - a comma-delimited list of XML configuration files to load. //一个xml配置文件以逗号分隔列表的加载。

  • actionPackages - a comma-delimited list of Java packages to scan for Actions.//一个Java包以逗号分隔列表的为actions检查

  • configProviders - a comma-delimited list of Java classes that implement the ConfigurationProvider interface that should be used for building the Configuration. //一个Java类以逗号分隔列表,实现ConfigurationProvider的接口,它可以被使用来创建配置

  • loggerFactory - The class name of the LoggerFactory implementation.//LoggerFactory类名的实现。

  • * - 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 staticcontent(内容)from its jar files, including Dojo JavaScript files (if using S2.0, or the Dojo plugin in S2.1+) andFreeMarker(自定义标签)templates(标准) for the Struts 2 tags that produce(提供) HTML.

在例子中我们一直用映射struts2的/* ,所以Struts2是打开所有的请求事物
这是因为Struts 2提供了静态的内容从它的包文件,
包含了dojo jav文件aScript,和自定义了标签为struts提供html;

If we change the filter mapping to something else, for example /*.html, we must take this in toaccount(说明) andextract(提取) the content that wouldnormally(正常的)be served from the Struts 2 jar files, or some othersolution(解决).

假如我们改变过滤器映射用其他的,例如/*.html,
我们必须把它加进去给它说明,和提取内容从Struts 2 包文件中。或者其他的解决

Since Struts 2.1.7, you are able(能够) to provide acomma(逗号)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 2.1.7,你是可以

原创粉丝点击