Is it OK to have multiple elements in the element in a J2EE web app version 2.4 compliant web.xml like this:
<filter-mapping>
<filter-name>SomeFilter</filter-name>
<url-pattern>*.htm</url-pattern>
<url-pattern>*.do</url-pattern>
</filter-mapping>
I looked up the XSD "web-app_2_4.xsd" file from here : http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd and the definition looks like this:
<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>
The URL pattern definition looks like this:
So I think, we can have multiple elements in the element. My Eclipse IDE however does not seem to agree with me, and expects a 'dispatcher' tag.
See image:
Clearly no, but you can have:
<filter-mapping>
<filter-name>SomeFilter</filter-name>
<url-pattern>*.htm</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SomeFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
Default is 1
for maxOccurs
and minOccurs
in sequence
element:
https://msdn.microsoft.com/en-us/library/ms256089(v=vs.110).aspx.
And choice
allows only one of the elements of it:
https://msdn.microsoft.com/en-us/library/ms256109(v=vs.110).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With