解决前后端集成后前端路由被后端拦截的问题

34 阅读1分钟
    /**  
    * 解决前后端集成后,前端的router和后端的contoller path之间的矛盾。当刷新页面或直接输入path时,报`Whitelabel Error Page,This application has no explicit mapping for /error, so you are seeing this as a fallback。`  
    * 参考:https://www.cxyzjd.com/article/Mr_EvanChen/83625082;https://www.codeleading.com/article/67134008368/  
    * @return  
    */  
    @Bean  
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer(){  
        return factory -> {  
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/index.html");  
            factory.addErrorPages(error404Page);  
        };  
    } 
}