The relationship between Servlet/Tomcat/SpringMVC

Open the source code of the servlet in idea:

 

 

It can be seen that a servlet is an interface; an interface specifies some specifications, so that some classes with certain commonalities can implement this interface, so that they all follow certain specifications.

Some people often think that the servlet directly handles the client's http request. In fact, this is not the case. The servlet does not listen to port 8080; it is a "container" to deal directly with the client, such as the commonly used tomcat.

The client's request is directly sent to tomcat, which listens to the port. After the request comes, it determines which servlet to hand the request to for processing according to the url and other information, and then calls the service method of that servlet. The service method returns a response object. This response is returned to the client.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325585391&siteId=291194637