title: How to redirect to an external url from spring mvc controller?
body: <p>This is my code inside the controller class. When the user enters localhost:8080/url, it retrieves the original long url let's say www.google.com saved in the database and then i want it to redirect to www.google.com but instead it redirects to localhost:8080/www.google.com and thus gives en error 500.</p>
  
  <pre><code> @RequestMapping(value="/{url}", method = RequestMethod.GET)
      public RedirectView getLongURl(@PathVariable("url") String url) {
  
          String original = database.getLongUrl(UrlShortener.decode(url));
          RedirectView redirectview = new RedirectView();
          redirectview.setUrl(original);
          return redirectview;
  
  }
  </code></pre>