title: java - Spring MVC: Redirect requests with old URLs to new URLs
body: <p>I have changed URL style of one of my websites to RESTful:</p>
  
  <pre><code>**Old URLs**                             **New URLs**
  /article/all.ab                          /articles
  /article/read.ab?id=345                  /articles/345/title-of-my-article
  </code></pre>
  
  <p>Until the search engines re-index my website with new URLs, people will continue to see old URLs on search engines. If they come to my site with an old URL, they will get a 404.</p>
  
  <p>I want to create a mechanism (by writing a controller, error handler or whatever) that would:</p>
  
  <ol>
  <li>catch a request whose mapping was not found</li>
  <li>check if there is a new URL mapped for this request path.</li>
  <li>If new URL was found, redirect to that URL.</li>
  <li>Else show "404 Page not found" page.</li>
  </ol>
  
  <p>How can this be done? </p>