The basic configuration is as follows
<!-- 配置servlet -->
<servlet>
<!-- 配置Servlet的名称 -->
<servlet-name>HelloServlet</servlet-name>
<!-- 配置Servlet全路径 -->
<servlet-class>servlet.HelloServlet</servlet-class>
</servlet>
<!-- 配置servlet映射 -->
<servlet-mapping>
<!-- 配置servlet名称,与上面那个要一样 -->
<servlet-name>HelloServlet</servlet-name>
<!-- 配置访问路径,即地址栏最后的路径 -->
<url-pattern>/hello</url-pattern>
</servlet-mapping>
However, after entering the following content in the address bar, it keeps displaying 404, the resource is not found.
Later, it was discovered that it was written <welcome-file-list>
into the tag pair, which also caused <servlet>
the tag pair to be red. Just write it outside.