Live2D

springboot学习之MVC

实现自定义视图拦截器

编写一个配置类(@Confifiguration),是WebMvcConfifigurerAdapter类型;不能标注@EnableWebMvc;
既保留了所有的自动配置,也能用我们扩展的配置;
原理:
1)、WebMvcAutoConfiguration是SpringMVC的自动配置类
2)、在做其他自动配置时会导入;@Import(EnableWebMvcConfiguration.class)
3)、容器中所有的WebMvcConfifigurer都会一起起作用;
4)、我们的配置类也会被调用;

全面接管MVC

 

1.我们需要在配置类中添加@EnableWebMvc即可; 

2.@EnableWebMvc注解中会import  delegatingWebMvcConfiguration类继承*Mvc*support类

3.在WebMvc*配置类上有注解验证是否存在*Mvc*support类来决定此配置类是否生效

@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
 

 

 

 

 

 

 

 

 

posted @ 2020-03-03 16:42  丁丁丁冲鸭丶  阅读(308)  评论(0)    收藏  举报