Detailed SpringMVC processor configuration

HandlerMapping is the processor mapper
HandlerAdapter is the processor adapter

The processor is the Controller control class

HandlerMapping: Find the matching processor (Controller) and return it to the front controller (DispatcherServlet)

HandlerAdapter: execute the processor found by HandlerMapping, and return the result (ModelAndView) to the front controller (DispatcherServlet)

Configuration method:

<!--  2. 配置映射器和适配器   -->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>

Written in springmvc.xml, it is equivalent to loading the methods of these two classes.
Now I just gave the method to find the processor, but also the path to the processor

    <!--  1. 注解扫描位置   -->
    <context:component-scan base-package="com.zrgj.controller"/>

A Handler (Controller) folder is established. When HandlerMapping is looking for a handler, it will be found from the @controller annotation under this folder.

Guess you like

Origin blog.csdn.net/hzl529/article/details/103124651