Configure Spring Boot for SPA frontend

前端 未结 3 744
谎友^
谎友^ 2020-12-10 19:21

I have application where whole frontend part is laying in resource. I would like to separate things apart. And have separate server for UI, provided by gulp, for example.

3条回答
  •  猫巷女王i
    2020-12-10 19:44

    For routing, according to this guide at Using "Natural" Routes (specifically here), you have to add a controller that does the following:

    @Controller
    public class RouteController {
        @RequestMapping(value = "/{path:[^\\.]*}")
        public String redirect() {
            return "forward:/";
        }
    }
    

    Then using Spring Boot, the index.html loads at /, and resources can be loaded; routes are handled by Angular.

提交回复
热议问题