title: How to use default-servlet-handler
body: <p>I want to configure Spring MVC to serve dynamic files mixed with static files, like this (URL => File):</p>
  
  <pre><code>/iAmDynamic.html   =&gt; /WEB-INF/views/iAmDynamic.html.ftl
  /iAmAlsoDynamic.js =&gt; /WEB-INF/views/iAmAlsoDynamic.js.ftl
  /iAmStatiHtml      =&gt; /iAmStatic.html
  </code></pre>
  
  <p>The <code>DispatchServlet</code> is mapped to <code>/</code>, annotation-based MVC configuration is enabled and I have a view controller like this (Simplified):</p>
  
  <pre><code>@Controller
  public class ViewController
  {
      @RequestMapping("*.html")
      public String handleHtml(final HttpServletRequest request)
      {
           return request.getServletPath();
      }
  
      @RequestMapping("*.js")
      public String handleJavaScript(final HttpServletRequest request)
      {
          return request.getServletPath();
      }
  }
  </code></pre>
  
  <p>The spring config looks like this:</p>
  
  <pre><code>&lt;context:component-scan base-package="myPackage" /&gt;
  
  &lt;mvc:default-servlet-handler /&gt;
  
  &lt;bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"&gt;
    &lt;property name="templateLoaderPath" value="/WEB-INF/views/" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"&gt;
    &lt;property name="cache" value="true" /&gt;
    &lt;property name="prefix" value="" /&gt;
    &lt;property name="suffix" value=".ftl" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Unfortunately it doesn't work. When this <code>&lt;mvc:default-servlet-handler /&gt;</code> is active then I can only access the <code>iAmStatic.html</code> file. When I disable the default-servlet-handler then only the dynamic stuff works. But I want both at once and that's exactly what this default-servlet-handler should do, or not? Where is the error here?</p>