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


}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM