扩展SpringMVC-Configuration

 

 

package com.syu.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Locale;

//如果要扩展Springmvc 官方建议我们这样去做 : 不要添加EnableWebMvc注解
@Configuration
//@EnableWebMvc EnableWebMvc导入了一个类:DelegatingWebConfiguation,作用是从容器中获取所有的WebConfig
public class MyMvcConfig implements WebMvcConfigurer {

    //视图跳转
    @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/kuang").setViewName("test");
    }


}

 

posted on 2020-04-05 07:53  萌萌手好冷  阅读(897)  评论(0编辑  收藏  举报