可以在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似乎不同意我的观点,并期望有一个“调度程序”标记 .
见图:
2 回答
maxOccurs
的1
和sequence
元素的minOccurs
的默认值为:https://msdn.microsoft.com/en-us/library/ms256089(v=vs.110).aspx .
并且
choice
只允许其中一个元素:https://msdn.microsoft.com/en-us/library/ms256109(v=vs.110).aspx
显然没有,但你可以: