How to define and in servlet 3.0's web.xml-less?

后端 未结 3 2623
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 19:36

I have existing web-app which I want to convert into web.xml-less of servlet\'s 3.0. I\'ve managed to make it working, however there are 2 tags in web.xml which I still don\

3条回答
  •  甜味超标
    2020-11-27 20:14

    For analog welcome-page-list put this in

    @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");
        }
    ...
    }
    

提交回复
热议问题