title: Redirect unknown requests to index.html in springboot
body: <p>I'm trying to get an Angular2 app served up through a springboot web application. I've found lots of examples of how to do this very simply:</p>
  
  <p><a href="https://spring.io/blog/2015/01/12/spring-and-angular-js-a-secure-single-page-application#using-spring-boot-cli" rel="nofollow noreferrer">https://spring.io/blog/2015/01/12/spring-and-angular-js-a-secure-single-page-application#using-spring-boot-cli</a></p>
  
  <p><a href="https://github.com/zouabimourad/angular2-spring/tree/master/front" rel="nofollow noreferrer">https://github.com/zouabimourad/angular2-spring/tree/master/front</a></p>
  
  <p><a href="https://github.com/ehirsch/spring-angular2" rel="nofollow noreferrer">https://github.com/ehirsch/spring-angular2</a></p>
  
  <p>However, these examples are very simple, and they just basically show how to display static content that happens to be Angular.</p>
  
  <p>None of them show how to handle any of the URLs (I think they're called routes) the Angular2 app uses that don't map to "real" resources.</p>
  
  <p>Eg. We have a "/login" route in the Angular app, but we don't have a @Controller/@RequestMapping("/login") for this, I want Spring to render index.html when it see's a request for "/login".</p>
  
  <p>Generically - I want Spring to render "index.html" whenever it can't an actual resource. Is there a way to set a default view for all requests that can't be mapped to something or found?</p>
  
  <p>I've tackled this before by using an htaccess file and have apache handle this:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule . index.html [L]
     ErrorDocument 404 /index.html
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>But I can't use apache or nginx in this case.</p>