如下所示,@Configuration声明其为一个配置类,实现WebMvcConfigurer接口重写Mvc配置
@EnableWebMvc注解加上后,发现原本的一些默认配置并没有生效,即该注解加上后将会使用本类的配置为mvc配置,完全覆盖默认配置。所以没有特殊要求尽量不要加上该注解
/**
* @author : phantom
* @desc :
* @create : 2019/12/4 10:30
*/
@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index");
}
}