[Thinking] MVC personal thoughts

1. The way to implement the MVC pattern using only servlets without using a framework at first is:

(1) Configure servlet and servlet-mapping in web.xml, and configure http requests to enter different servlets. Here, the suffix or carried parameters of each request can be used as a distribution marker, as the implementation of the controller.

For example: the url-pattren of servlet-mapping is /demo/, the request url is /demo/flag, and the flag is distributed to each controller business module

(2) The controller can call the processing logic in the model to complete the corresponding function, and finally use dispatcher or forward or redirect to the corresponding jsp

(3) The corresponding jsp is the role of the view.


2. Spring basic principles:

(1) All requests will enter dispatcherServlet, and then call handler Mapping through dispatcherServet to call the corresponding controller, before and after preAction/postAction may be added, as well as some interceptor AOP functions

(2) After the controller processes the business logic and calls the model, the dispatcherserlvet will call the viewResolver to call the corresponding view


Guess you like

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