Changing default welcome-page for spring-boot application deployed as a war

前端 未结 4 1968
梦谈多话
梦谈多话 2020-12-01 08:21

I was trying to find a way to change the default welcome-page for a spring-boot application that is being deployed as a war in production but I can\'t find a way to do it wi

4条回答
  •  时光取名叫无心
    2020-12-01 08:56

    It's not too hard to do... you just need to forward the default mapping...

    @Configuration
    public class DefaultView extends WebMvcConfigurerAdapter{
    
        @Override
        public void addViewControllers( ViewControllerRegistry registry ) {
            registry.addViewController( "/" ).setViewName( "forward:/yourpage.html" );
            registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
            super.addViewControllers( registry );
        }
    }
    

提交回复
热议问题