---
title: "在web.xml中配置一个servlet"
author: "bd2007"
date: "2011-08-04T09:42:56Z"
tags: []
categories: ["编程语言"]
slug: "web-xml-servlet"
draft: false
lastmod: "2011-08-04T09:42:56Z"
id: 1139734
url: "https://bd2007.iteye.com/blog/1139734"
---

```java
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"	xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"	id="webapp_id" version="2.5">	<display-name>student</display-name>	<welcome-file-list>		<welcome-file>index.html</welcome-file>		<welcome-file>index.htm</welcome-file>		<welcome-file>index.jsp</welcome-file>		<welcome-file>default.html</welcome-file>		<welcome-file>default.htm</welcome-file>		<welcome-file>default.jsp</welcome-file>	</welcome-file-list>	<servlet>		<servlet-name>test</servlet-name>		<servlet-class>com.test.test</servlet-class>		<load-on-startup>1</load-on-startup>	</servlet>	<servlet-mapping>		<servlet-name>test</servlet-name>		<url-pattern>/test</url-pattern>	</servlet-mapping></web-app>
```

<servlet-name>test</servlet-name>servlet的名称
<servlet-class>com.test.test</servlet-class>servlet的类全称（包名.类名）
<load-on-startup>1</load-on-startup>是否在服务器启动时就加载，如果不用在服务器启动时就加载可以去掉此项
<url-pattern>/test</url-pattern>servlet的访问路径