In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the working principle of Spring MVC". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the working principle of Spring MVC"?
Introduction to Spring MVC Framework
Spring MVC is a follow-up product of SpringFrameWork and has been integrated into Spring Web Flow.
The Spring MVC framework provides a full-featured MVC module for building web applications, using the Spring pluggable architecture, and you can choose whether to use the built-in Spring web framework or a web framework like struts. Through the interface, the Spring framework is highly configurable and contains a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, iText and POI. The Spring MVC framework doesn't know which views to use, so it doesn't force you to use only JSP technology.
Spring MVC separates the roles of controllers, model objects, dispatchers, and handler objects, making them easier to customize.
Spring's MVC framework is mainly composed of DispatcherServlet, processor mapping, processor (controller), view parser and view.
Spring MVC schematic diagram
SpringMVC interface interpretation
DispatcherServlet:
Spring provides a front-end controller through which all requests are distributed uniformly. Before DispatcherServlet can distribute the request to Spring Controller, you need to locate the specific Controller with the help of the HandlerMapping provided by Spring.
HandlerMapping:
Ability to complete customer request to Controller mapping.
Controller:
The above requests need to be processed for concurrent users, so the implementation of the Controller interface must be thread-safe and reusable.
Controller will handle user requests, which is consistent with the role played by Struts Action. Once the Controller has finished processing the user request, the ModelAndView object is returned to the DispatcherServlet front-end controller, and the ModelAndView contains the model (Model) and view (View).
From a macro point of view, DispatcherServlet is the controller of the whole Web application; from a micro point of view, Controller is the controller in the processing of a single Http request, and ModelAndView is the model (Model) and view (View) returned in the process of Http request.
ViewResolver:
The view parser (ViewResolver) provided by Spring looks for View objects in the Web application and renders the corresponding results to the customer.
Operation principle of SpringMVC
Client request submitted to DispatcherServlet
One or more HandlerMapping is queried by the DispatcherServlet controller to find the Controller that processes the request
DispatcherServlet submits the request to Controller
After calling the business logic for processing, Controller returns ModelAndView
DispatcherServlet queries one or more ViewResoler view parsers to find the view specified by ModelAndView
The view is responsible for displaying the results to the client
DispatcherServlet is the core of the whole Spring MVC. It is responsible for receiving HTTP requests, organizing and coordinating the various components of the Spring MVC. Its main work is as follows:
1. Intercept URL requests that conform to a specific format.
two。 Initialize the WebApplicationContext corresponding to the DispatcherServlet context and associate it with the WebApplicationContext of the business layer and persistence layer.
3. Initialize the components of Spring MVC and assemble them into DispatcherServlet.
Thank you for your reading, the above is the content of "what is the working principle of Spring MVC". After the study of this article, I believe you have a deeper understanding of what the working principle of Spring MVC is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.