web.xml 配置文件?
<?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_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>WebDay01</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> <!-- 1.分为servlet 和 servlet-mapping 两个部分 2.servlet 分为 servlet-name 和servlet-class 3.servlet-mapping 分为 servlet-name和 URL-pattern两部分 --> <servlet> <servlet-name>ServletDemo</servlet-name> <!-- servlet的名字 --> <servlet-class>com.aaa.servlet.ServletDemo</servlet-class><!--相对路径,包名+类名 --> </servlet> <servlet-mapping> <servlet-name>ServletDemo</servlet-name> <url-pattern>/zxf</url-pattern> <!--配置的URL路径 可以随意起名字 注意规范性! 需要配置的原因?--> </servlet-mapping>
![](https://img2018.cnblogs.com/blog/1602553/201906/1602553-20190621204832592-1078866894.png)
<servlet> <servlet-name>ServletDemo01</servlet-name> <servlet-class>com.aaa.servlet.ServletDemo01</servlet-class> </servlet> <servlet-mapping> <servlet-name>ServletDemo01</servlet-name> <url-pattern>/zxh</url-pattern> </servlet-mapping> <servlet> <servlet-name>HttpServletDemo</servlet-name> <servlet-class>com.aaa.servlet.HttpServletDemo</servlet-class> </servlet> <servlet-mapping> <servlet-name>HttpServletDemo</servlet-name> <url-pattern>/666</url-pattern> </servlet-mapping> <!--创建的 servlet 这里会自动生成! --> <servlet> <description></description> <display-name>HttpServletText</display-name> <servlet-name>HttpServletText</servlet-name> <servlet-class>com.aaa.servlet.HttpServletText</servlet-class> </servlet> <servlet-mapping> <servlet-name>HttpServletText</servlet-name> <url-pattern>/HttpServletText</url-pattern> </servlet-mapping> </web-app>