对于那些乐于探索的小伙伴来说,不会仅仅止步于怎么配置web.xml文件,他们更会关注背后的秘密,今天我将
写下我的探索之路
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
<display-name>xx平台</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:applicationContext.xml,xx.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>/WEB-INF/views/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
相信web开发人员一定对上面的配置很熟悉,这是我节选自web.xml中的一小段配置,下面我将为大家讲述这段配置
背后的秘密,先看一张图:
complexType "javaee:web-appType"
Namespace: | |
---|---|
Content: | complex, 3 attributes, 31 elements |
Defined: | globally in web-app_2_5.xsd, see XML source |
Includes: | definitions of 3 attributes and 17 elements |
Used: | at 1 location |
XML Representation Summary | |||
---|---|---|---|
<... | |||
= | xsd:ID | ||
= | xsd:boolean | ||
= | "2.5" | ||
> | |||
Content: | ((javaee:description*, javaee:display-name*, javaee:icon*) | javaee:distributable | javaee:context-param | javaee:filter | javaee:filter-mapping | javaee:listener | javaee:servlet | javaee:servlet-mapping | javaee:session-config | javaee:mime-mapping | javaee:welcome-file-list | javaee:error-page | javaee:jsp-config | javaee:security-constraint | javaee:login-config | javaee:security-role | (javaee:env-entry*, javaee:ejb-ref*, javaee:ejb-local-ref*, javaee:service-ref*, javaee:resource-ref*, javaee:resource-env-ref*, javaee:message-destination-ref*, javaee:persistence-context-ref*, javaee:persistence-unit-ref*, javaee:post-construct*, javaee:pre-destroy*) | javaee:message-destination | javaee:locale-encoding-mapping-list)* | ||
</...> |
javaee:context-param (type javaee:param-valueType ), javaee:description (type javaee:descriptionType ), javaee:display-name (type javaee:display-nameType ), javaee:distributable (type javaee:emptyType ), javaee:ejb-local-ref (type javaee:ejb-local-refType ), javaee:ejb-ref (type javaee:ejb-refType ), javaee:env-entry (type javaee:env-entryType ), javaee:error-page (type javaee:error-pageType ), javaee:filter (type javaee:filterType ), javaee:filter-mapping (type javaee:filter-mappingType ), javaee:icon (type javaee:iconType ), javaee:jsp-config (type javaee:jsp-configType ), javaee:listener (type javaee:listenerType ), javaee:locale-encoding-mapping-list (type javaee:locale-encoding-mapping-listType ), javaee:login-config (type javaee:login-configType ), javaee:message-destination (type javaee:message-destinationType ), | javaee:message-destination-ref (type javaee:message-destination-refType ), javaee:mime-mapping (type javaee:mime-mappingType ), javaee:persistence-context-ref (type javaee:persistence-context-refType ), javaee:persistence-unit-ref (type javaee:persistence-unit-refType ), javaee:post-construct (type javaee:lifecycle-callbackType ), javaee:pre-destroy (type javaee:lifecycle-callbackType ), javaee:resource-env-ref (type javaee:resource-env-refType ), javaee:resource-ref (type javaee:resource-refType ), javaee:security-constraint (type javaee:security-constraintType ), javaee:security-role (type javaee:security-roleType ), javaee:service-ref (type javaee:service-refType ), javaee:servlet (type javaee:servletType ), javaee:servlet-mapping (type javaee:servlet-mappingType ), javaee:session-config (type javaee:session-configType ), javaee:welcome-file-list (type javaee:welcome-file-listType ) |
---|
All Direct / Indirect Based Elements (1):
通过上面的数据,相信大家应该明白web.xml可以按照文章开头配置的原因了吧。
如果还想了解context-param、error-page等一些配置的由来,可以点开具体的项:
比如javaee:error-page