springmvc三大核心组件

springmvc三大核心组件

1.处理器映射器

HandlerMapping:

org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping(传统开发方式)
org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping(过时的注解开发方式)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping(最新版本的注解开发方式,在springmvc.xml中进行更改,在springmvc的jar包的配置文件中,可以明显的看出只有调用了前两个包。而我们则在springmvc.xml替换为第三个)

2.处理器适配器(在controller中选择方法)

HandlerAdapter:

org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter(传统开发方式)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter(过时的注解开发方式)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter(最新版本的注解开发方式)

但使用注解驱动 < mvc:annotation-driven/> 代替了上述两个
<–注解驱动:用于加载新版本的处理器映射器和处理器适配器–>

3.视图解析器:



 

这里有一些疑惑,为什么不直接将视图解析器的配置也封装到"注解驱动"中,然后用标签接收前缀和后缀,这也就不用去写类名了

4.SpringMVC处理流程:

1.发出连接请求
2.请求经过进入处理器映射器
3.处理器映射器找到相应的Controller
4.将controller返回给DispatcherServlet
5.请求转发给处理器适配器
6.处理器适配器找到具体的方法 ,执行方法,返回modelAndView
7.视图解析器得到modelAndView中的逻辑视图
8.返回物理视图即view对象(个人理解为jsp页面)
9.返回HTML页面给浏览器

springmvc三大核心组件_第1张图片

你可能感兴趣的:(springmvc三大核心组件)