扩展springMVC

编写一个配置类(@Configuration),是WebMvcConfigurerAdapter类型;不能标注@EnableWebMvc

既保留了所有的自动配置,也能用我们扩展的配置

@Configuration
public class Config extends WebMvcConfigurerAdapter {//WebMvcConfigurerAdapt
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        super.addViewControllers(registry);
        //浏览器发送"/test" 请求来到success页面
        registry.addViewController("/test").setViewName("success");
    }
}

猜你喜欢

转载自www.cnblogs.com/gxlaqj/p/11680070.html