Spring MVC

Controller ViewName

 1 方案1 直接实现WebMvcConfigurer
 2@Configuration
 3public class WebMvcConfg implements WebMvcConfigurer {
 4    @Override
 5    public void addViewControllers(ViewControllerRegistry registry) {
 6         registry.addViewController("/index").setViewName("index");
 7    }
 8}
 9方案2 直接继承WebMvcConfigurationSupport
10@Configuration
11public class WebMvcConfg extends WebMvcConfigurationSupport {
12   @Override
13   public void addViewControllers(ViewControllerRegistry registry) {
14        registry.addViewController("/index").setViewName("index");
15   }
16}