Routing from Spring MVC to Angular and vice versa


If I have Spring MVC application which is using dispatcher, view resolver and controller and if I need some pages to be created using angular and some pages to be created using jsp of the spring mvc.
My question is: how to route to the angular page if we were navigating the spring mvc page (jsp page) and how to route for the spring mvc page (the jsp page) if the user was in the angular page?
Shall I consider them two separated applications? Even, how to be able to route between them (to spring mvc jsp from angular and to angular from spring jsp)?
What is the required configuration at the dispatcher config file and which annotation to be used in the mvc controller? Same thing about angular, what is needed to be done?


Its been a long long time since I even thought about Spring MVC, but I work with Angular daily.

Regardless of how you “get” the index.html with Angular to the user, your back-end doesn’t need to route the user beyond the index.html. So if the user is going to the following url:

You need to return the index.html. This way Angular will handle showing that page.

You will probably need to lookup how to “always return index.html” using Spring MVC. Generally using MVC is mostly overkill as the “V” (View) in the stack is 100% handled by Angular, you just need to create an api for Angular to get data from.

Finally you should not need to declare any routes for your “pages”, or potentially even need a controller as you should be able to setup Spring to just return the index.html for any non-api route that you can’t find and let Angular handle the “page not found” sort of handling.