I successfully integrated the Angular2 application with the Spring backend to download after this tutorial by putting the compiled JS resources in / ui. Everything works fine, the Angular2 application is accessible through the appname / ui URL.
However, I would like to know if there is a way to tell Spring “pass-through” URLs that the children of the / ui path, as Spring is currently intercepting every targeting request / ui / *, preventing the Angular2 router from moving correctly by resources along the path / ui.
Currently, I only have this mapping in one of my controllers:
@RequestMapping(value = "/ui") public String uiIndex() { return "/ui/index.html"; }
In this case, the interface is correctly displayed in / ui, but Spring sends me errors and 404s for everything under it , when I access them directly from the browser . Navigating the router inside the Angular2 application works fine.
EDIT
I add the compiled Angular2 resources from target / ui to the static / ui folder with this configuration (my project uses maven build):
<resource> <directory>${project.basedir}/src/main/resources</directory> <includes> <include>*.properties</include> <include>templates/*.*</include> </includes> </resource> <resource> <directory>target/ui</directory> <targetPath>static/ui</targetPath> </resource>
As is clear, the only problem is that when I enter the URL in the browser, for example / ui / home / settings, Spring intercepts the request and throws errors. I can happily go to / ui and then to / home / settings in the context of Angular.
source share