标签:ecif 多个 context require 应用程序 listen tco alt art
一、web.xml文件介绍
web.xml file contains several elements that are required for a Facelets application. All of the following are created automatically when you use NetBeans IDE to create an application.web.xml主要用来配置Filter、Listener、Servlet等。但是要说明的是web.xml并不是必须的,一个web工程可以没有web.xml文件。
WEB容器的加载顺序是:
ServletContext -> context-param -> listener -> filter -> servlet。在web.xml文件中最好按照这种顺序配置这些元素,以兼容较低版本的Tomcat。
WEB容器启动时,加载过程顺序如下:
二、web.xml of hello1 analysis
• xml文档第一行的声明和它的文档元素描述信息。
<?xml version="1.0" encoding="UTF-8"?>
• Servlet 3.1 deployment descriptor:
<web-app version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
...
</web-app>
xsi:schemaLocation="{namespace} {location}
• A context parameter specifying the project stage:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
• A servelt element and its servlet-mapping element specifying the FacesServlet. All files with the .xhtml suffix will be matched:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet> 用来声明一个servlet的数据,主要有以下子元素:<servlet-name> 指定servlet的名称<servlet-class> 指定servlet的类名称<jsp-file> 指定web站台中的某个JSP网页的完整路径<init-param> 用来定义参数,可有多个init-param。<load-on-startup> 当值为正数或零时,从小到大加载。否则第一次访问时加载。<servlet-mapping> 用来定义servlet所对应的URL,包含两个子元素<servlet-name> 指定servlet的名称<url-pattern> 指定servlet所对应的URL
• 会话超时配置:
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
• A welcome-file-list element specifying the location of the landing page:
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
参考:(https://javaee.github.io/tutorial/webapp003.html#GJWTV)
(https://www.jianshu.com/p/0e53eff3b920)
(https://www.cnblogs.com/LiZhiW/p/4313844.html)
Analysis of Web.xml in Hello1 project
标签:ecif 多个 context require 应用程序 listen tco alt art
原文地址:https://www.cnblogs.com/qqq-65536/p/10840363.html