首页 文章

web.xml中的多个URL模式元素

提问于
浏览
8

可以在J2EE Web应用程序版本2.4兼容的web.xml中的元素中包含多个元素,如下所示:

<filter-mapping>
    <filter-name>SomeFilter</filter-name>
    <url-pattern>*.htm</url-pattern>
    <url-pattern>*.do</url-pattern>
</filter-mapping>

我从这里查找了XSD "web-app_2_4.xsd"文件:http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd,定义如下:

<xsd:complexType name="filter-mappingType">
    <xsd:annotation>
      <xsd:documentation>
            some documentation here
      </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>

URL模式定义如下所示:

所以我认为,我们可以在元素中包含多个元素 . 然而,我的Eclipse IDE似乎不同意我的观点,并期望有一个“调度程序”标记 .

见图:
Eclipse error

2 回答

相关问题