SpringMVC

作者: Samon_ | 来源:发表于2018-08-31 17:38 被阅读0次
  1. 客户端(浏览器)请求在SpringMVC中的流程

  2. 在SpringMVC中有两个应用上下文
    a)当DispatcherServlet启动当时候,它会创建一个应用上下文,并加载配置文件或配置类中声明的Bean。DispatcherServlet加载包含Web组件的Bean,如控制器(Controller)、视图解析器(View Resolver)以及处理器映射(Handler Mapping)
    b)ContextLoaderListener加载应用中的其他Bean。这些Bean通常是驱动应用后端的中间层和数据层组件

  3. 使用 @EnableWebMvc 注解,需要以编程的方式指定视图文件相关配置;
    使用 @EnableAutoConfiguration 注解,会读取 application.properties 或 application.yml 文件中的配置。

  4. @EnableWebMvc、WebMvcConfigurationSupport、WebMvcConfigurationAdapter三者的关系:

a) @EnableWebMvc+extends WebMvcConfigurationAdapter,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置

b) extends WebMvcConfigurationSupport,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置

c) extends WebMvcConfigurationAdapter,在扩展的类中重写父类的方法即可,这种方式依旧使用springboot的@EnableAutoConfiguration中的设置

相关文章

网友评论

      本文标题:SpringMVC

      本文链接:https://www.haomeiwen.com/subject/phykwftx.html