开发者社区> 问答> 正文

tomcat 5.5部署项目报错,关于Filter的错误。

1
2
3
4
5
6
tomcat 5.5部署项目报错,关于Filter的错误。
请教各位大神,什么原因?

展开
收起
落地花开啦 2016-05-30 15:10:08 1959 0
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人

    tomcat 5.5不支持 Servlet2.5
    你的web.xml的写法是Servlet 2.5的。
    注意看你的文件头部:

    <web-app version="2.5"  
    xmlns="http://java.sun.com/xml/ns/javaee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 

    在2.5版本的xsd里面:

     <xsd:sequence>
          <xsd:element name="filter-name"
      type="javaee:filter-nameType"/>
          <xsd:choice minOccurs="1" maxOccurs="unbounded">
    <xsd:element name="url-pattern"
        type="javaee:url-patternType"/>
    <xsd:element name="servlet-name"
        type="javaee:servlet-nameType"/>
          </xsd:choice>
          <xsd:element name="dispatcher"
      type="javaee:dispatcherType"
      minOccurs="0" maxOccurs="4"/>
        </xsd:sequence>

    是这样的
    而在2.4版本:
    是这个:

      <xsd:complexType name="filter-mappingType">
        <xsd:annotation>
          <xsd:documentation>

    Declaration of the filter mappings in this web
    application is done by using filter-mappingType.
    The container uses the filter-mapping
    declarations to decide which filters to apply to a request,
    and in what order. The container matches the request URI to
    a Servlet in the normal way. To determine which filters to
    apply it matches filter-mapping declarations either on
    servlet-name, or on url-pattern for each filter-mapping
    element, depending on which style is used. The order in
    which filters are invoked is the order in which
    filter-mapping declarations that match a request URI for a
    servlet appear in the list of filter-mapping elements.The
    filter-name value must be the value of the filter-name
    sub-elements of one of the filter declarations in the
    deployment descriptor.

          </xsd:documentation>
        </xsd:annotation>
    
        <xsd:sequence>
          <xsd:element name="filter-name"
         type="j2ee:filter-nameType"/>
          <xsd:choice>
     <xsd:element name="url-pattern"
           type="j2ee:url-patternType"/>
     <xsd:element name="servlet-name"
           type="j2ee:servlet-nameType"/>
          </xsd:choice>
          <xsd:element name="dispatcher"
         type="j2ee:dispatcherType"
         minOccurs="0" maxOccurs="4"/>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:ID"/>
      </xsd:complexType>

    区别在于 和

    2019-07-17 19:20:37
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Apache Tomcat 的云原生演进 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载