首页
学习
活动
专区
圈层
工具
发布

springboot中WebMvcConfigurationSupport、WebMvcConfigurationAdapter区别

2、@EnableWebMvc、WebMvcConfigurationSupport、WebMvcConfigurationAdapter @EnableWebMvc=WebMvcConfigurationSupport...,使用了@EnableWebMvc注解等于扩展了WebMvcConfigurationSupport但是没有重写任何方法 @EnableWebMvc+extends WebMvcConfigurationAdapter...,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的WebMvcAutoConfiguration中的设置 @EnableWebMvc+extends WebMvcConfigurationSupport...只会使用@EnableWebMvc extends WebMvcConfigurationSupport,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@WebMvcAutoConfiguration...)说明,当没有WebMvcConfigurationSupport对应的bean时,才会使用该配置,所以当我们使用继承WebMvcConfigurationSupport的方式类扩展mvc时,原有的配置则无效

3K30
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    小BUG大原理:重写WebMvcConfigurationSupport后SpringBoot自动配置失效

    2.猜想验证 其实上面扯了这么多,还没说到关键点为什么重写了WebMvcConfigurationSupport会导致后台接收不了FormData?...果不其然,重写过WebMvcConfigurationSupport后,少了formParams这个属性,而formParams包含了我们想要的参数ids[]。...至于为什么重写WebMvcConfigurationSupport会丢失formParams?是不是毫无头绪?别急,我们先看下这个formParams是什么。...那至于为什么重写了WebMvcConfigurationSupport就会导致自动配置失效了呢?再看下WebMvcAutoConfiguration的头部注解描述。...@ConditionalOnMissingBean({WebMvcConfigurationSupport.class}),意思就是Spring容器中没有WebMvcConfigurationSupport

    1.1K20

    Spring Boot 中自定义 SpringMVC 配置,到底继承谁?

    WebMvcConfigurationSupport 前面两个都好理解,还有一个 WebMvcConfigurationSupport ,这个又是干什么用的呢?...那么在这里我自定义 SpringMVC 配置的时候,就是通过继承 WebMvcConfigurationSupport 类来实现的。...在 WebMvcConfigurationSupport 类中,提供了用 Java 配置 SpringMVC 所需要的所有方法。我们来看一下这个方法的摘要: ?...在这里首先大家需要明确的是,WebMvcConfigurationSupport 类本身是没有问题的,我们自定义 SpringMVC 的配置是可以通过继承 WebMvcConfigurationSupport...换句话说,在纯 Java 配置的 SSM 中,如果你需要自定义 SpringMVC 配置,你离不开 WebMvcConfigurationSupport ,所以在这种情况下建议通过继承 WebMvcConfigurationSupport

    76130

    Spring Boot2 系列教程(十八)Spring Boot 中自定义 SpringMVC 配置

    WebMvcConfigurationSupport 前面两个都好理解,还有一个 WebMvcConfigurationSupport ,这个又是干什么用的呢?...那么在这里我自定义 SpringMVC 配置的时候,就是通过继承 WebMvcConfigurationSupport 类来实现的。...在 WebMvcConfigurationSupport 类中,提供了用 Java 配置 SpringMVC 所需要的所有方法。我们来看一下这个方法的摘要: ?...在这里首先大家需要明确的是,WebMvcConfigurationSupport 类本身是没有问题的,我们自定义 SpringMVC 的配置是可以通过继承 WebMvcConfigurationSupport...换句话说,在纯 Java 配置的 SSM 中,如果你需要自定义 SpringMVC 配置,你离不开 WebMvcConfigurationSupport ,所以在这种情况下建议通过继承 WebMvcConfigurationSupport

    57320

    重学SpringBoot3-EnableWebMvcConfiguration

    SpringMVC 重要配置类—— WebMvcAutoConfiguration 类进行了介绍,下面介绍下它引入的另外几个重要组件,它们分别是 EnableWebMvcConfiguration 类、WebMvcConfigurationSupport...implements ResourceLoaderAware {} } 在日常开发中我们不经常直接与它交互,这个类扩展自 DelegatingWebMvcConfiguration,后者又扩展自 WebMvcConfigurationSupport...2、WebMvcConfigurationSupport类 org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport...WebMvcConfigurationSupport 是 Spring MVC 框架的核心配置支持类,提供了 Spring MVC 基础设施的背后配置。...@Configuration(proxyBeanMethods = false) public class DelegatingWebMvcConfiguration extends WebMvcConfigurationSupport

    40610

    Spring Boot 静态资源处理

    但是如果你想要自己配置一些项目的设置,你可以在@Configuration注解的配置类上增加@EnableWebMvc或者继承WebMvcConfigurationSupport和WebMvcConfigurationAdapter...正文: 首先解析@EnableWebMvc 、WebMvcConfigurationSupport和WebMvcConfigurerAdapter # 在spring-boot+spring mvc...首先,@EnableWebMvc=WebMvcConfigurationSupport,使用了@EnableWebMvc注解等于扩展了WebMvcConfigurationSupport但是没有重写任何方法...extends WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置 extends WebMvcConfigurationSupport...WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式依旧使用springboot的@EnableAutoConfiguration中的设置 具体哪种方法适合,看个人对于项目的需求和要把控的程度,在WebMvcConfigurationSupport

    1.8K60

    项目里出现两个配置类继承WebMvcConfigurationSupport时,为什么只有一个会生效(源码分析)

    为什么我们的项目里出现两个配置类继承WebMvcConfigurationSupport时,只有一个会生效。...其中一种原因就是,自己写的配置类也继承了WebMvcConfigurationSupport,当项目出现两个配置类都继承该类时,只会讲第一个配置类生效,至于为什么,就是今天博主需要讲解的,我们必须了解一些...this.knownSuperclasses.containsKey(superclass)) {76 //如果我们第一个继承了WebMvcConfigurationSupport...的配置类,已经被扫描到,就会添加一个map缓存,77 //下一个也继承了WebMvcConfigurationSupport的配置类,将不在解析,直接返回null。...我直接把这个问题用源码的方式讲解清楚,方便大家明白为什么配置两个WebMvcConfigurationSupport类,只有一个生效。我正在参与2024腾讯技术创作特训营最新征文,快来和我瓜分大奖!

    46531

    SpringMVC源码学习(四)- SpringBoot的整合你真的会吗?

    如上图所示,这个WebAutoConfiguration会在类级别注解扫描的时候被扫描到,但是它和webmvcConfigurationSupport是不兼容的,所以这个类只对WebMvcConfigurer...---- 那么如果我们直接继承WebMvcConfigurationSupport会怎样? 首先我们要知道我们的AutoWebMvcConfiguration是不会起作用了。...但是我们发现WebMvcConfigurationSupport中有很多@Bean的注解,意思就是说只要我们的自定义类上具有@Configuration注解就可以独善其身了。...毕竟WebMvcConfigurationSupport里包含了很多组件。直接用就好了。当然如果我们需要自定义的话就得重写,当然必须要对一些组件特别了解,否则可能会出问题。...第二种方式是继承WebMvcConfigurationSupport,因为WebMvcConfigurationSupport包含了很多@Bean的对Spring注册,所以可以直接使用,但对于比较复杂的方法重写上需要足够的了解才可以

    46930

    一波带走,教你Spring Boot如何扩展、接管MVC?

    在这里需要声明一个前提:**配置类上没有标注@EnableWebMvc并且没有任何一个配置类继承了WebMvcConfigurationSupport**。至于具体原因,下文会详细解释。...{} 明白了,@EnableWebMvc这个注解实际上就是导入了一个WebMvcConfigurationSupport子类型的配置类而已。...而WEB模块的自动配置类有这么一行注解@ConditionalOnMissingBean(WebMvcConfigurationSupport.class),源码如下: @Configuration(proxyBeanMethods...一切都已经揭晓了,@EnableWebMvc导入了一个WebMvcConfigurationSupport类型的配置类,导致了自动配置类WebMvcAutoConfiguration标注的@@ConditionalOnMissingBean...(WebMvcConfigurationSupport.class)判断为false了,从而自动配置类失效了。

    51630
    领券