springMVC (a) of the process springMVC

MVC pattern

MVC model represents the Model-View-Controller (Model - View - Controller) pattern. This mode is used for layered application development.

Model (Model)  - access to a model representative of object data or JAVA POJO. It can also carry logic, update controller when data changes.

View (View)  - included in the model view representative of visualization.

Controller (Controller)  - role of controller in the model and view. It controls data flow model objects, view and update the data changes. It is the view and the model separated.

In the early development of Java web, using the MVC pattern is jsp + servlet + java bean achieved, the principle as shown below:

However, the use of jsp + servlet + java bean development is more complex.

springMVC mode

        Spring MVC architecture using loosely coupled pluggable module, more flexible and extensible than other MVC framework, Spring MVC annotation by using a set of the Java class becomes a front-end controller (the Controller), need not implement any interface, while, Spring MVC support for RES in the form of a URL request, in addition, Spring MVC in the data binding, view resolution, there are many good performance on the localization process and handle the static resources.

        Spring MVC around the DispatcherServlet (front controller) as the center, the DispatcherServlet (front controller) is central Spring MVC, and the same idea of ​​MVC, which takes the user from the view request and dispatches to the corresponding processor, and decided to use which view to the data presented to the user.

SpringMVC request corresponding steps as follows:

1, the user sends a request to the server, the request is controlled Spring distal capture Servelt DispatcherServlet

2, to reach the web.xml file DispatcherServlet. View meets the requirements of url

3、DispatcherServlet就会查询springmvc的配置文件。找HandlerMapping.

4、根据bean的名称查找相应的controller.

5、Controller.执行完成后,向DispatcherServlet 返回一个ModelAndView对象

6、根据返回的ModelAndView在找springmvc配置文件中视图解析器。

7、ViewResolver 结合Model和View,来渲染视图

8、将渲染结果返回给客户端

Guess you like

Origin www.cnblogs.com/zjc364259451/p/11449269.html