In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
A brief introduction to spring
SpringMVC is a module of the spring framework, and springMVC and spring do not need to be developed through an intermediate integration layer.
SpringMVC is a mvc-based web framework.
Both spring web mvc and Struts2 belong to the framework of the presentation layer, which is part of the Spring framework, as we can see from the overall structure of Spring:
2. The application of MVC in Bamp S system.
1. The user initiates a request request to the controller (Controller)
Control to receive the data requested by the user and delegate it to the model for processing
two。 The controller processes the data through the model (Model) and gets the processing result.
Models usually refer to business logic
3. The result of model processing is returned to the controller.
4. The controller displays the model data in the View
The model in web can not display the data directly on the view, it needs to be done through the controller. The data can be displayed in the view if the model is used in the Cstroke S application.
5. The controller responds the view response to the user
Display the desired data or processing results to the user through the view.
Third, the working principle of spring
(1)。 Initiate a request to the front-end controller (DispatcherServlet)
(2)。 The front-end controller requests HandlerMapping to find Handler, which can be found according to xml configuration and comments.
(3)。 Processor mapper HandlerMapping returns Handler to the front-end controller
(4)。 The front-end controller calls the processor adapter to execute the Handler
(5)。 Processor adapter to execute Handler
(6) .Handler returns ModelAndView to the adapter after execution is completed.
(7)。 The processor adapter returns ModelAndView to the front-end controller (an underlying object of the springmvc framework, including Model and View)
(8)。 The front controller requests the view parser to parse the view and resolve the real view (jsp...) according to the logical view name.
(9)。 The view parser returns View to the front-end controller
(10)。 The front controller performs view rendering, which fills the request field with model data (in the ModelAndView object).
(11)。 The front controller responds to the result to the user.
IV. Introduction of components
1. Front-end controller DispatcherServlet (does not need to be developed by engineers), which is provided by the framework
Function: receive requests, respond to results, equivalent to transponders, central processing units. With dispatcherServlet, the coupling between other components is reduced.
When the user request arrives at the front-end controller, it is equivalent to the mvc pattern in which the cpowerhouse Servlet is the center of the whole process control. It invokes other components to deal with the user's request. The existence of dispatcherServlet reduces the coupling between components.
2. Processor mapper HandlerMapping (which does not require engineer development), provided by the framework
Function: to find the Handler based on the requested url
HandlerMapping is responsible for finding the Handler processor according to the user's request. Springmvc provides different mappers to achieve different mapping methods, such as configuration file mode, implementation interface mode, annotation mode and so on.
3. Processor Adapter HandlerAdapter
Function: execute Handler according to specific rules (rules required by HandlerAdapter)
Processors are executed through HandlerAdapter, which is an application of the adapter pattern, and more types of processors can be executed by extending adapters.
4. Processor Handler (needs to be developed by engineers)
Note: when writing Handler, follow the requirements of HandlerAdapter so that the adapter can execute Handler correctly.
Handler is the back-end controller following the DispatcherServlet front-end controller. Handler processes specific user requests under the control of DispatcherServlet.
Because Handler involves specific user business requests, engineers are generally required to develop Handler according to business requirements.
5. View parser View resolver (which does not need to be developed by engineers), provided by the framework
Function: perform view parsing, parsing to a real view according to the logical view name (view)
View Resolver is responsible for generating the View view of the processing result. View Resolver first parses the logical view name into the physical view name, that is, the specific page address, and then generates the View view object. Finally, the View is rendered and the processing result is displayed to the user through the page. The springmvc framework provides many types of View views, including jstlView, freemarkerView, pdfView, and so on.
In general, the model data needs to be displayed to the user through the page through the page tag or page template technology, and the specific page needs to be developed by the engineer according to the business requirements.
6. View View (engineer is required to develop jsp...)
View is an interface, and the implementation class supports different View types (jsp, freemarker, pdf...)
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.