how to specify welcome-file-list in WebApplicationInitializer.onStartup()

前端 未结 4 1523
醉话见心
醉话见心 2020-12-10 02:30

Currently I have a web application where we are using web.xml to configure the application. The web.xml has welcome-file-list.

  
   ...
   &l         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 03:00

    @EnableWebMvc
    @Configuration
    @ComponentScan("com.springapp.mvc")
    public class MvcConfig extends WebMvcConfigurerAdapter {
    ...
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/*.html").addResourceLocations("/WEB-INF/pages/");
    }
    
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/index.html");
    }
    ...
    }
    

    This might help.

提交回复
热议问题