1

I have been trying to get the URL which was typed wrongly by user before redirection to the custom error page.

Below is what I have but I don't see a way to get the wrong URL from the request variable

@RequestMapping(value = "/errors/404.html")
private String defaultPage(HttpServletRequest request,Exception e){
        request.getRequestURL().toString(); // this prints /error/404.html
        ...
        ...
}

I expect to see URL something like www.example.com/home2 which was keyed in by the user. However when I debug I can see the following

enter image description here

How do I retrieve the /home2 from the request ?

abiieez
  • 3,139
  • 14
  • 57
  • 110

1 Answers1

0

You can use a RequestContextListener to get the request bound to the current Thread.

Check this answer:

What's the best way to get the current URL in Spring MVC?

Community
  • 1
  • 1
Andres
  • 10,561
  • 4
  • 45
  • 63