扩展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");
    }


}

猜你喜欢

转载自www.cnblogs.com/lotus-wmm/p/12635758.html