title: Spring Boot get the browser request URL
body: <p>I have a simple rest controller which captures errors. I want to get the actual URL that the browser sent to server, but the servlet is giving me a different URL.</p>
  
  <p>If I navigate to <code>127.0.0.1/abc</code> a 404 error is triggered, and it's routed to <code>/error</code> handler as defined. However, the output gives me the result <code>127.0.0.1/error</code> instead of <code>127.0.0.1/abc</code>. How can I obtain the original URL?</p>
  
  <pre><code>@RestController
  public class IndexController implements ErrorController {
  
      @RequestMapping("/")
      public String index() {
          return "OK";
      }
  
      @RequestMapping("/error")
      public String error(HttpServletRequest request) {
          System.out.println("ERR: " + request.getRequestURL() + " : " + request.getRequestURI());
          return "ERR";
      }
  
      @Override
      public String getErrorPath() {
          return "/error";
      }
  }
  </code></pre>