扩展SpringMVC-Configuration

吃可爱长大的小学妹 提交于 2020-04-05 18:07:31

 

 

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


}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!