springboot2.0MVC配置过时替换

springboot1.X MVC配置过时,这个不适合2.x使用

@Configuration
public class mvc_t extends WebMvcConfigurerAdapter  {
}

最好使用

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/link").setViewName("link");

    }
    }

这个方法不会使springboot自动配置失效。

如果使用下面这个方式,则会是MVC的自动配置失效

@Configuration
public class mvc_t extends WebMvcConfigurationSupport {
}

猜你喜欢

转载自blog.csdn.net/ouyang_ouba/article/details/92399764
今日推荐