Changing default URL mapping for Serving Static Content in Spring Boot

后端 未结 5 1710
鱼传尺愫
鱼传尺愫 2021-01-19 13:29

My static resources stopped working as soon as I added a new Controller (non rest) in my application with the following mapping

@RequestMapping(value = \"/{p         


        
5条回答
  •  温柔的废话
    2021-01-19 14:29

    i dint use @EnableWebMVC. This worked for me and spring boot service server static content for default localhost:8888/ and also for localhost:8888/some/path/

    @Configuration
    public static class WebServerStaticResourceConfiguration extends WebMvcConfigurerAdapter {
        @Override
        public void addViewControllers(ViewControllerRegistry registry) {
            registry.addViewController("/some/path/").setViewName("forward:/index.html");
        }
    }
    

提交回复
热议问题