In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the working principle and mechanism and configuration of springMVC. 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 the working principle, mechanism and configuration of springMVC.
working principle
The following is a schematic diagram of how springMVC works:
1. The client sends a http request to the web server, and the web server parses the http request. If it matches the request mapping path of DispatcherServlet (specified in web.xml), the web container transfers the request to DispatcherServlet.
2. After receiving the request, DipatcherServlet will find the processor (Handler) to process the request based on the information of the request (including URL, Http method, request header and request parameter Cookie, etc.) and the configuration of HandlerMapping.
3-4. DispatcherServlet finds the corresponding Handler according to HandlerMapping, gives the processing power to Handler (Handler encapsulates the specific processing), and then specific HandlerAdapter makes specific calls to Handler.
5. Handler will return a ModelAndView () object to DispatcherServlet after the data processing is completed.
6. The ModelAndView () returned by Handler is only a logical view, not a formal view. DispatcherSevlet converts the logical view into a real view View through ViewResolver.
7. Dispatcher parses the parameters in ModelAndView () through model and finally shows the complete view and returns it to the client.
What is the working mechanism?
Invocation of Control (continued)
Then add to (2): mainly summarize the key operations of the processing logic of Control
The key to dealing with control is that the handlerMappings collection of DispatcherServlet matches a handler in each handlerMapping object according to the requested URL, and when the match succeeds, it will return the processing connection handlerExecutionChain object of this handler. This handlerExecutionChain object will contain multiple user-defined handlerInterceptor objects.
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
/ * *
* Return the HandlerExecutionChain for this request.
*
Tries all handler mappings in order.
* @ param request current HTTP request
* @ return the HandlerExecutionChain, or null if no handler could be found
, /
Protected HandlerExecutionChain getHandler (HttpServletRequest request) throws Exception {
For (HandlerMapping hm: this.handlerMappings) {
If (logger.isTraceEnabled ()) {
Logger.trace (
"Testing handler map [" + hm + "] in DispatcherServlet with name'" + getServletName () + "'")
}
HandlerExecutionChain handler = hm.getHandler (request)
If (handler! = null) {
Return handler
}
}
Return null
}
Of the three methods defined in the handlerInterceptor interface, preHandler and postHandler are executed before and after handler execution, respectively, and afterCompletion is executed before view rendering is completed and before DispatcherServlet returns.
Would like to know more about technical knowledge sharing, please refer to the source code: http://minglisoft.cn/technology
If friends need, please add a ball: 2042849237
Configuration of springmvc.xml
Configuration of the view parser:
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.