Overview of 01.SpringMVC

springMVC architecture

SpringMVC module is a Spring framework, Spring and SpringMVC without integration by the integration of the intermediate layer. SpringMVC WEB-based framework is the MVC architecture.
SpringMVC frame is a request-driven Web-based framework was used to design the front end controller mode, and then distributed to the appropriate page controller (act / processor) according to the mapping rule for processing the request.

 

 

 request processing flow springMVC

 

Component Description:

1.DispatcherServlet: front controller. A user request arrives at the front end of the controller, it is equivalent mvc mode c, dispatcherServlet center of the entire process is controlled by the other components of the processing which calls the user's request, the presence DispatcherServlet reduces coupling between components, system scalability improve. Implemented by the frame
2.HandlerMapping: processor mapper. HandlerMapping Handler that is responsible for finding url processor according to user requests, springmvc mapper provides different ways to achieve different mapping, according to certain rules to find, for example: xml configuration, implement the interface mode, annotation methods. Implemented by the frame
3.Handler: processor. Handler is the second back-end DispatcherServlet front controller, under the control of DispatcherServlet Handler for specific user requests are processed. Since Handler related to specific user service request, it is generally required Handler programmers based on business needs.
4.HandlAdapter: processor adapter. HandlerAdapter execution by a processor, which is an application of the adapter mode, the processor may be more types of expansion performed by the adapter. Implemented by the framework.
5.ModelAndView springmvc is encapsulated object model and view the package together.
6.ViewResolver: view resolver. ViewResolver responsible for generating the processing result View view, ViewResolver resolved to a specific name is the view of the physical page address according to the logical name of the view, then the view object generates View, View finally render the processing result to the user through display pages.
7View: springmvc is encapsulated objects, an interface, a lot of framework springmvc View view type, comprising: jspview, pdfview, jstlView, freemarkerView, pdfView like. You need to model data show generally by page or tag page by page template technology to users, programmers need to develop a specific page based on business needs.

SpringMVC execution flow:
1. The user sends a request to the front end of the controller the DispatcherServlet
2.DispatcherServlet HandlerMapping call processor receives the request mapper.
3. Processor mapper find specific processor upon request url, HandlerExecutionChain generation processor execution chain (including a processor and a processor interceptors objects) together back to DispatcherServlet.
The acquisition processor Handler 4.DispatcherServlet HandlerAdapter adapter processor performs a series of operations HandlerAdapter process, such as: parameters of encapsulation, data format conversion, data validation operations
5. Handler execution processor (the Controller, also called page controller).
6.Handler completed execution returns ModelAndView
7.HandlerAdapter Handler will ModelAndView execution result is returned to the DispatcherServlet
8.DispatcherServlet ModelAndView will pass ViewReslover view resolver
after 9.ViewReslover returns parsed DETAILED View
10.DispatcherServlet render view of View (ie model data model filled view).
11.DispatcherServlet response to the user.

Special Bean used in DispatcherServlet

DispatcherServlet default WebApplicationContext as context, we look at what special Bean this context are:

1, Controller: a processor / controller page, do the things in MVC C, the control logic to the front controller, for processing the request;

2, HandlerMapping: request to the mapping processor, if successful returns a mapping HandlerExecutionChain object (Handler comprising a processor (page controller) object, a plurality of interceptors HandlerInterceptor) objects; BeanNameUrlHandlerMapping as Bean name and the URL mapping, the mapping is successful the Bean is here processor;

3, HandlerAdapter: HandlerAdapter the processor will be packaged as adapters to support multiple types of processors, namely the application of design patterns adapter, making it easy to support many types of processors; as SimpleControllerHandlerAdapter will be achieved Bean Controller Interface adaptation, and performs the function of a processor disposed handleRequest method;

. 4, ViewResolver: ViewResolver name will resolve to a particular logical view View, this strategy mode, it is easy to replace other view technologies; InternalResourceViewResolver as to map the logical name for the view jsp view;

5, LocalResover: locale resolution, since Spring supports internationalization, so LocalResover resolve Locale information for the client in order to facilitate internationalization;

6、ThemeResovler:主题解析,通过它来实现一个页面多套风格,即常见的类似于软件皮肤效果;

7、MultipartResolver:文件上传解析,用于支持文件上传;

8、HandlerExceptionResolver:处理器异常解析,可以将异常映射到相应的统一错误界面,从而显示用户友好的界面(而不是给用户看到具体的错误信息);

9、RequestToViewNameTranslator:当处理器没有返回逻辑视图名等相关信息时,自动将请求URL映射为逻辑视图名;

10、FlashMapManager:用于管理FlashMap的策略接口,FlashMap用于存储一个请求的输出,当进入另一个请求时作为该请求的输入,通常用于重定向场景,后边会细述。

springMVC架构SpringMVC是Spring框架的一个模块,Spring和SpringMVC无需通过中间整合层进行整合。SpringMVC是基于MVC架构的WEB框架。SpringMVC框架是一个基于请求驱动的Web框架,使用了前端控制器模式来进行设计,再根据请求映射规则分发给相应的页面控制器(动作/处理器)进行处理。

Guess you like

Origin www.cnblogs.com/deityjian/p/11493528.html