Java web servlet hierarchy from scratch (4)

servlet hierarchy

Servlet — "GenericServlet —> HttpServlet
There are many types of HTTP requests, and there are four commonly used:
GET, read,
POST, save
PUT, modify
DELETE, delete
GenericServlet, implement Servlet access, and shield its subclasses from infrequently used methods , The subclass only needs to rewrite the service method. HttpServlet inherits GenericServlet and distributes it according to the request type. GET enters the doGET method, and POST enters the doPOST method. The Servlet class defined by the developer only needs to inherit HttpServlet, and doGET and doPOST again.

We can directly inherit httpservlet instead of writing service method in servlet
Insert picture description here

You can use the postman tool to verify our request
!](https://img-blog.csdnimg.cn/20210125131350820.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9NLmNz0FF,sizeXmNz0FF_size,color4ub5
Insert picture description here
Insert picture description here
Next section jsp

Guess you like

Origin blog.csdn.net/qq_43928549/article/details/113108412