<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0"
         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"
         metadata-complete="true">
</web-app>

可以直接使用


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0"
         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"
         metadata-complete="true">

    <!--注册Servlet-->
    <servlet>
        <servlet-name>MyServlet</servlet-name>
        <!--指定Servlet类-->
        <servlet-class>com.yang.servlet.MyServlet</servlet-class>
    </servlet>
    <!--给定访问路径-->
    <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <!--指定访问路径-->
        <url-pattern>MyServlet</url-pattern>
    </servlet-mapping>


</web-app>