How can we redirect to required angular page (routing page) from spring boot controller – angular integrated inside spring boot

Published

I have integrated angular application inside spring boot application.. i.e. angular build files are placed inside static folder of spring boot application like following image.
enter image description here

I have defined two angular routing urls like

 1. http://localhost:8080/pageone
 2. http://localhost:8080/pagetwo

when I access above urls from browser, which are handled by server (spring boot application) directly and not by the angular. so I end up in page not found.

We can redirect to index page from spring boot like this

@GetMapping("/")
public RedirectView welcome(RedirectAttributes attributes) {
    //attributes.addFlashAttribute("flashAttribute", "redirectWithRedirectView");
    //attributes.addAttribute("pageToRequest", "paymentoverview");
    return new RedirectView("index.html");
}

but we can only redirect to index.html page not to routing urls "/pageone" or "/pagetwo".

I don’t want to end up in index page.

Somehow I wan't to end up in respective page that I accessed from browser automatically, 
even after redirect to index page also fine.

I tried to send attributes along with index.html, but it doesn’t work.
How can we fix this problem.

Source: Angular Questions

Published
Categorized as angular, angular-routing, redirect, spring-boot Tagged , , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq