1、web.xml servlet配置解释
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!--第一个servlet-->
<servlet>
<servlet-name>customServlet</servlet-name><!-- 自定义servlet名,用该名指代下面的类 -->
<servlet-class>com.mobao.servlet.HelloServlet</servlet-class>
<load-on-startup>2</load-on-startup><!-- 服务器启动即初始化servlet,否则只用请求才会创建servlet -->
</servlet>
<servlet-mapping>
<servlet-name>customServlet</servlet-name><!--自定义所对应的servlet 对应的调用url接口-->
<url-pattern>/hello1</url-pattern>
</servlet-mapping>
<!--第二个servlet-->
<servlet>
<servlet-name>genericservlet</servlet-name>
<servlet-class>com.mobao.servlet.GenericServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>genericservlet</servlet-name>
<url-pattern>/hello2</url-pattern>
</servlet-mapping>
</web-app>
网友评论