Servlet: A framework/tool, through which the development project (back-end API) can be more convenient, and Request and Response have been encapsulated.
(1) Creation of Servlet
①Create a webapp maven project
Until the project is created.
②Add the source code root directory
③Add servlet reference
When configuring pom.xml, recommended: mvnrepository
the dependency add the code to the dependencies pom.xml in
④Configure the servlet configuration file web.xml
Fixed writing in web.xml:
<?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_3_1.xsd"
version="3.1"
metadata-complete="true">
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>