spring boot 設置首頁

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


@Configuration
public class DefaultView implements WebMvcConfigurer  {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:index.jsp");
        WebMvcConfigurer.super.addViewControllers(registry);
    }

}

 

index.jsp 路徑:resource/static/index.jsp

 

WebMvcConfigurerAdapter 已經過期,雖然可以用,但是看起來感覺很不爽。

如果使用 WebMvcConfigurationSupport 又會導致 自配配置失效

https://www.cnblogs.com/deng720/p/8989388.html

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章