<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置Servlet的基本信息 -->
<!-- 配置Servlet的名称(名称可以任意写,一般情况下和类的名称是相同的) -->
<!-- 配置Servlet类的包名+类名的全路径 Class.forName("包名+类名"); -->
<servlet>
<servlet-name>ServletDemo1</servlet-name>
<servlet-class>cn.itcast.servlet.ServletDemo1</servlet-class>
<!-- 初始化参数 -->
<init-param>
<param-name>username</param-name>
<param-value>root</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>123</param-value>
</init-param>
<!-- 配置自动加载 -->
<!-- 指定Servlet的自动加载 值:正整数 值越小,优先级越高(越是先加载) -->
<load-on-startup>2</load-on-startup>
</servlet>
<!-- 配置Servlet的访问路径 -->
<!-- 配置Servlet名称(注意:该名称和<servlet>标签下的<servlet-name>的名称必须是相同的) -->
<!-- 配置访问路径(值的写法有哪种)访问:http://localhost/day08/servlet1 -->
<servlet-mapping>
<servlet-name>ServletDemo1</servlet-name>
<url-pattern>/servlet1</url-pattern>
</servlet-mapping>
<!-- 配置全局的初始化参数 -->
<context-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
来源:oschina
链接:https://my.oschina.net/u/2306156/blog/410216