spring boot 设置首页

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a919423654/article/details/87867059

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

猜你喜欢

转载自blog.csdn.net/a919423654/article/details/87867059