<?xml version="1.0" encoding="UTF-8"?>
<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" id="WebApp_ID" version="3.0">
<display-name>Hello_Servlet1</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>src.First_Servlet</servlet-class>
<!-- 配置在serlvet里面,指定serlvet被创建的时机, 若为负数,则在运行浏览器的时候被创
建, 若为0或者正数,则在当前Servlet 容器启动时被创建,参数越小越先被创建-->
<load-on-startup>-1</load-on-startup>
</servlet>
<!-- 一个servlet可以有多个 servlet-mapping -->
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet2</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>HelloServlet2</servlet-name>
<servlet-class>src.Second_Servlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet2</servlet-name>
<!-- 使用* 通配符, 前面不能加 “/” 但/*是合法的 -->
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
<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" id="WebApp_ID" version="3.0">
<display-name>Hello_Servlet1</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>src.First_Servlet</servlet-class>
<!-- 配置在serlvet里面,指定serlvet被创建的时机, 若为负数,则在运行浏览器的时候被创
建, 若为0或者正数,则在当前Servlet 容器启动时被创建,参数越小越先被创建-->
<load-on-startup>-1</load-on-startup>
</servlet>
<!-- 一个servlet可以有多个 servlet-mapping -->
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet2</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>HelloServlet2</servlet-name>
<servlet-class>src.Second_Servlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet2</servlet-name>
<!-- 使用* 通配符, 前面不能加 “/” 但/*是合法的 -->
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>