擴展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