SpringMVC的API
找到这个网址中的1.11. MVC Config的Static Resources
先说下原因吧:使用了@EnableWebMvc
我们自定义的WebConfig使用了@EnableWebMvc,使用@EnableWebMvc,会自动导入DelegatingWebMvcConfiguration类
DelegatingWebMvcConfiguration类,它继承WebMvcConfigSupport。
有这个WebMvcConfigSupport的时候,WebMvcAutoConfiguration这个类就不生效了。
因为点进去WebMvcAutoConfiguration发现有一个注解
@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
意思是有WebMvcConfigurationSupport的话就不初始化WebMvcAutoConfiguration类。
所以导致我们写的WebConfig使用了@EnableWebMvc后,通过DelegatingWebMvcConfiguration加载进来,自己写的配置就没有生效。