分析hello1项目里面的web.xml

在example目录下的web\jsf\hello1\target\hello1\WEB-INF路径里可以找到hello1的web.xml

<?xml version="1.0" encoding="UTF-8"?>

这句话表示了xml的版本:1.0 和 编码:utf-8

<web-app xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="3.1">

本xml文件中要用到某些来自xsi代表的“http://www.w3.org/2001/XMLSchema-instance”这个命名空间的元素

 

<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>

 

这一段指示了上下文参数。上下文参数提供Web应用程序所需的配置信息。应用程序可以定义自己的上下文参数。此外,JavaServer Faces技术和Java Servlet技术定义了应用程序可以使用的上下文参数。

复制代码
<servlet>
<!-- servlet的内部名称 --> <servlet-name>Faces Servlet</servlet-name>
<!-- servlet的类全名: 包名+简单类名 --> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- servlet的映射配置 --> <servlet-mapping>
<!-- servlet的内部名称,一定要和上面的内部名称保持一致!! --> <servlet-name>Faces Servlet</servlet-name>
<!-- servlet的映射路径(访问servlet的名称) --> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <!-- 设置Session超时时间方式 --> <session-config>
<!-- 客户端连续两次与服务器交互间隔时间最长为30分钟 --> <session-timeout>30 </session-timeout> </session-config>
复制代码

上面的结果就是把某个servlet类和url路径绑在一起了,意思是我们访问 /url名字 实际上就是在访问某个servlet类,并设置客户端连续两次与服务器交互间隔时间最长为30分钟。

<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

welcome-file-list是一个配置在web.xml中的一个欢迎页,用于当用户在url中输入工程名称或者输入web容器url(如http://localhost:8080/)时直接跳转的页面.

posted @ 2019-05-07 22:30  jk212  阅读(130)  评论(0编辑  收藏  举报