多个 url 模式的部署问题? [英] deployment issue with multiple url-patterns?

查看:34
本文介绍了多个 url 模式的部署问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序部署在 tomcat 上,servlet 版本为 2.4,并且运行良好.

I have a application which is deployed on tomcat with servlet version 2.4, and its working nicely.

当我尝试在 websphere 上部署相同的应用程序时,部署失败.我发现多个 url-patterns 导致了这个问题.

When i tried to deploy the same application on websphere, deployment failed. I found that multiple url-patterns causing the issue.

示例代码:-

<filter> 
      <filter-name>ABCD</filter-name> 
      <filter-class>com.x.y.filters.ABCD</filter-class> 
</filter> 
<filter-mapping> 
      <filter-name>ABCD</filter-name>
      <url-pattern>/A/*</url-pattern> 
      <url-pattern>/B/*</url-pattern> 
      <url-pattern>/C/*</url-pattern> 
      <url-pattern>*.jsp</url-pattern> 
</filter-mapping>

所以我的问题是,为什么 servlet 版本 2.4 不能与 websphere 一起使用(注意:如果我使用 3.0 它的工作).根据我的理解,特定于我们正在部署的 servlet 版本.

So my question is that why servlet version 2.4 is not working with websphere (NOTE: if i use 3.0 its working). In my understanding servlet version specific to what we are deploying.

我正在使用支持 3.0 和更低 servlet 版本的 websphere 8.

I am using websphere 8 which supports 3.0 and lower servlet versions.

请帮助我更好地理解.

推荐答案

您必须为每个 url 模式设置单独的过滤器映射:

You must have individual filter mapping for each url pattern:

<filter-mapping>
   <filter-name>ABCD</filter-name>
   <url-pattern>/A/*</url-pattern>
</filter-mapping>    

<filter-mapping>
   <filter-name>ABCD</filter-name>
   <url-pattern>/B/*</url-pattern>
</filter-mapping>    

Servlet 2.4 规范定义:

Servlet 2.4 specification defines:

  <xsd:choice>
   <xsd:element name="url-pattern"
         type="j2ee:url-patternType"/>
   <xsd:element name="servlet-name"
         type="j2ee:servlet-nameType"/>
  </xsd:choice>

Servlet 2.5 引入了对多次出现的支持,这就是它适用于 servlet 3.0 的原因.

Servlet 2.5 introduced support for multiple occurences that is why it works in servlet 3.0 for you.

Tomcat 6 支持 servlets 2.5 规范.问题是当 web.xml 说它是 2.4 版本应用程序时,为什么多次出现过滤器映射.恕我直言,这是供应商特定的增强".它们不满足 servlet 规范契约.另一方面,您也没有这样做,因为您的 web.xml 无效.他们决定忽略指定的版本.WebSphere 做它应该做的 - 它拒绝您无效的 web.xml.

Tomcat 6 supports servlets 2.5 specification. The question is why multiple occurences of filter mapping works in it when web.xml says that it is 2.4 version application. IMHO it is vendor specific "enhancement". They do not fullfill servlet specification contract. On the other hand you do not as well because your web.xml is not valid. They decided to ignore the specified version. WebSphere does what it shall - it rejects your invalid web.xml.

这篇关于多个 url 模式的部署问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆