0

I work with spring boot, thymeleaf, spring security and angularjs I want all url invalid to return to the home page. The login page is managed by thymeleaf and the rest by angularjs

So i used a @Controller to forward all invalid url to the localhost:8080/:

@Controller
public class AccueilController {

    // Match everything without a suffix (so not a static resource)
    @RequestMapping(value = "/{path:[^\\.]*}")
    public String redirect() {
        // Forward to home page so that route is preserved.
        return "forward:/";
    }
}

when connecting if I type localhost:8080/XXXXthat forward me to the racine after login but if I type localhost:8080/XXXX/XXXX that give me a 404 error after connection I don't have that problem because Angular forward all url correctly.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
AyoubMK
  • 526
  • 1
  • 4
  • 19

1 Answers1

-1

That's not the default behavior of the web applications. I sugest you to customize the not found page (Spring Boot and custom 404 error page) and then from there create a link to your home;

Community
  • 1
  • 1