zoukankan      html  css  js  c++  java
  • Springboot @EnableWebMvc 注解

    @EnableWebMvc 注解的源码如下

    可以看出,真正起作用的是DelegatingWebMvcConfiguration这个类,点进去看一下这个类

    这个类继承了 WebMvcConfigurationSupport 这个类,点开这个类

    public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
    
    	protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    	}
    
    	protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    	}
    
    	protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    	}
    
    	protected void addViewControllers(ViewControllerRegistry registry) {
    	}
    	....
    }
    

    可以看到这个类中都是一些空方法,只是保留了最基本的 MVC 的功能,并不具备其它的扩展功能

    并且如果容器中存在  WebMvcConfigurationSupport 这个类,那么 springboot 对于 springmvc 的自动配置将会失效

    如下:springboot 对于 mvc 模块的配置就在 WebMvcAutoConfiguration 这个类中,如果容器中没有 WebMvcConfigurationSupport 这个类的情况下, springboot 对于 mvc 模块的自动配置才会生效,而 @EnableWebMvc 注解就是向容器中添加 WebMvcConfigurationSupport 这个类,所以它会导致 springboot 对 mvc 模块的自动配置失效

  • 相关阅读:
    centos7下配置时间同步服务器
    交换机简单配置(转)
    ubuntu16.04安装docker CE
    docker下使用DB2
    iptables之centos6版本详解
    iptables之centos6版本常用设置
    iptables介绍iptables和netfilter
    git的使用学习(九)搭建git服务器
    js 图片预览
    ps -ef | grep java 查看所有关于java的进程
  • 原文地址:https://www.cnblogs.com/xiaomaomao/p/13998924.html
Copyright © 2011-2022 走看看