title: Spring MVC 4 Java Config with Static HTML Views
body: <p>I am trying to build a single page HTML/Angular app backed by Spring MVC 4 without .jsp files.</p>
  
  <p>When the user arrives to the root URL (<a href="http://myapp.com/" rel="nofollow">http://myapp.com/</a> for example), I want to send the single page HTML document (index.html). </p>
  
  <p>However, I am new to Spring MVC's Java config and cannot work out the proper combination of <code>ServletMapping</code>, <code>ViewResolver</code>, and <code>ResourceHandler</code>.</p>
  
  <p>I know that there may be some additional configuration for the "default" or "index" page, but I may be mistaken.</p>
  
  <p>So how do I make a Java configured Spring MVC 4 application send an html file?</p>
  
  <p>File structure</p>
  
  <pre><code>/src
    '-/main
       |-/web-inf
       '-/webapp
           |-index.html (want to send this)
           '-/app
              |-/partials
              '-app.js 
  </code></pre>
  
  <p>WebAppConfig.java</p>
  
  <pre><code>@Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/").addResourceLocations("/index.html");
  }
  </code></pre>
  
  <p>IndexController.java</p>
  
  <pre><code>@RequestMapping("/")
  public void index() {
  
    System.out.println("pls"); // executes
    // Have tried returning "index" and "index.html"
  }
  </code></pre>
  
  <p>WebInitializer.java</p>
  
  <pre><code>@Override
  protected String[] getServletMappings() {
    // have tried with "/" as well
    return new String[] { "/*" };
  }
  </code></pre>