我正在开发一个基于反应的单页面应用程序的弹簧后端,我正在使用react-router进行客户端路由.
在index.html页面旁边,后端提供路径上的数据/api/**.
为了从我的应用程序src/main/resources/public/index.html的根路径上提供我的index.html,/我添加了一个资源处理程序
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/").addResourceLocations("/index.html");
}
Run Code Online (Sandbox Code Playgroud)
我想要的是在没有其他路由匹配的情况下提供index.html页面,例如当我调用除了以外的路径时/api.
如何在春季配置这种全能路线?
spring spring-mvc catch-all single-page-application spring-boot