Spring catch all route for index.html

后端 未结 6 1909

I\'m developing a spring backend for a react-based single page application where I\'m using react-router for client-side routing.

Beside the index.html page the back

6条回答
  •  感情败类
    2020-11-29 00:14

    Found an answer by looking at this question

    @Bean
    public EmbeddedServletContainerCustomizer notFoundCustomizer() {
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/"));
            }
        };
    }
    

提交回复
热议问题