web.xml中的多个URL模式元素 [英] Multiple URL pattern elements in web.xml
问题描述
在J2EE Web应用程序版本2.4兼容的web.xml中,元素中有多个元素可以这样: ><过滤器映射>
< filter-name> SomeFilter< / filter-name>
< url-pattern> *。htm< / url-pattern>
< url-pattern> *。do< / url-pattern>
< / filter-mapping>
我从这里查找了XSDweb-app_2_4.xsd文件:。
而选择
仅允许其中的一个元素:
https://msdn.microsoft.com/en-us/library/ms256109(v = vs.110).aspx
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:
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
这篇关于web.xml中的多个URL模式元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!