title: 404 error redirect in Spring with Java config
body: <p>As you know, in XML, the way to configure this is:</p>
  
  <pre><code>&lt;error-page&gt;
      &lt;error-code&gt;404&lt;/error-code&gt;
      &lt;location&gt;/my-custom-page-not-found.html&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p>But I haven't found a way to do it in Java config. The first way I tried was:</p>
  
  <pre><code>@RequestMapping(value = "/**")
  public String Error(){
      return "error";
  }
  </code></pre>
  
  <p>And it appeared to work, but it has conflicts retrieving the resources. </p>
  
  <p>Is there a way to do it?</p>