1

My application is a spring boot and angular 5 with angular as dependency added into spring boot app, Packaging is like

Backend Jar:

enter image description here

The angular app jar in in BackendJar\BOOT-INF\lib\angularapp.jar

The application loads the home page on load home(/) no problem here but here I have a scenario where I need to navigate to home (/) when some condition is met in controller, like below:

@RequestMapping(value="/",method = RequestMethod.GET)
public String getUser(HttpServletRequest request) {
   if(request.getHeader("USER")=="something") {
      return "home"; //return Home page
   } else {
      return "error"; //error page here
   }
}

But spring throws a 404 when I try to navigate to home from controller like above. If I remove the @RequestMapping(value="/",method = RequestMethod.GET) it happily loads the home component.

What am I doing wrong here:

Do I need to give the exactly html name here or do I need to give the name in the router. {path: 'home', component: HomeComponent} or home.component.html

br.julien
  • 3,420
  • 2
  • 23
  • 44
juniorDeveloper
  • 225
  • 3
  • 18
  • you can try this http://www.baeldung.com/spring-redirect-and-forward – AchillesVan Mar 13 '18 at 20:23
  • it is not working. Is this because of the packaging, since I packaged all angular into a jar and including it as part of springboot jar. ? @georgesvan – juniorDeveloper Mar 13 '18 at 22:18
  • please check, whether this might help you: https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/url-to-view-mapping.html – xerx593 Mar 14 '18 at 08:48
  • @juniorDeveloper folow this course. you 'll learn everyting about Angula 4 and spring boot: https://www.udemy.com/angular-4-java-developers/learn/v4/content – AchillesVan Mar 14 '18 at 19:16

0 Answers0