WebMvcConfigurationSupport和WebMvcConfigurer的区别

springboot2.0之后配置拦截器extends 的WebMvcConfigurerAdapter过时,取而代之的是WebMvcConfigurationSupport

查看源码发现: WebMvcConfigurerAdapter只是对WebMvcCofigurer的空实现,而WebMvcConfigurationSupport的实现的方法更全面

但是继承WebMvcConfigurationSupport会发现Spring Boot的WebMvc自动配置失效(WebMvcAutoConfiguration自动化配置),导致无法视图解析器无法解析并返回到对应的视图

WebMvcConfigurationSupport-->不需要返回逻辑视图,可以选择继承此类

WebMvcCofigurer-->返回逻辑视图,可以选择实现此方法,重写addInterceptor方法

WebMvcConfigurationSupport和WebMvcConfigurer的区别_第1张图片

关于WebMvcAutoConfiguration的源码分析参考:https://blog.csdn.net/qq_26000415/article/details/78998669

你可能感兴趣的:(WebMvcConfigurationSupport和WebMvcConfigurer的区别)