Java 过滤器映射调度器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2968621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 15:00:55  来源:igfitidea点击:

Dispatcher for Filter Mapping

javajsp

提问by George

I have an app written for Servlet Spec 2.4 with an old webserver designed for Servlet Spec 2.3. The web.xml file has the following syntax:

我有一个为 Servlet Spec 2.4 编写的应用程序,其中有一个为 Servlet Spec 2.3 设计的旧网络服务器。web.xml 文件具有以下语法:

<filter-mapping> 
    <filter-name>sitemesh</filter-name>  
    <url-pattern>*.action</url-pattern>   
    <dispatcher>REQUEST</dispatcher>    
    <dispatcher>FORWARD</dispatcher> 
</filter-mapping> 

How can I re-write this mapping to be servlet 2.3 compliant?

如何重写此映射以符合 servlet 2.3?

回答by ZZ Coder

Just remove the <dispatcher> tags.

只需删除 <dispatcher> 标签。

Servlet 2.3 doesn't support dispatchers. If you don't do include, it doesn't make any difference. If you do have included servlet/JSP, you need to rename them so they are not filtered to get the exact behavior as 2.4.

Servlet 2.3 不支持调度程序。如果你不包括,它没有任何区别。如果您确实包含了 servlet/JSP,则需要重命名它们,以免过滤它们以获得与 2.4 相同的行为。

回答by BalusC

You can just remove the <dispatcher>entries. The Servlet 2.3 filter by default dispatches on everything and that's just okay. Sitemesh even mentions at its own site that it's compatible with Servlet 2.3. Here's an extract from their site:

您可以删除<dispatcher>条目。默认情况下,Servlet 2.3 过滤器会分派所有内容,这没关系。Sitemesh 甚至在其自己的站点上提到它与 Servlet 2.3 兼容。这是他们网站的摘录:

SiteMesh is a Servlet Filter and therefore requires a container that conforms to the Servlet 2.3specification.

SiteMesh 是一个 Servlet 过滤器,因此需要一个符合Servlet 2.3规范的容器。