Typical hierarchical design of MVC, we can refer to the hierarchical design model given in Alibaba’s development manual, as shown in the figure:

Among them, the arrow in the figure above indicates a direct dependency relationship. The open interface layer can depend on the Web layer, or directly depend on the Service layer, and so on (you can refer to Alibaba Development Manual for the specific logic to be implemented in each layer).

System layered design is a design idea, is to let each layer of objects have an independent responsibility, and then let the multi-layer objects cooperate (coupling) to complete a complete function. Doing so makes the system more scalable, but it also makes the overall system more difficult to operate.

Objects and methods that need to be used at each layer:

Client <– –> request processing layer (Web) : request is the object representing the HTTP request information, response is the object representing the HTTP response information.

When the browser sends a request to access a Servlet in the server, the server calls the service method in the Servlet to process the request. Request and Response objects are created before the service method is called. The request object encapsulates the request information that the browser sends to the server (request line, request header, request entity, etc.), and the response object encapsulates the response information that the server sends to the browser (status line, response header, response entity). After the execution of the service method, The server then takes out the data in response and sends it to the browser in accordance with the format of HTTP protocol.