title: Is My Spring-MVC ContentNegotiatingViewResolver setup correctly? How can I send 404 error for unsupported media types?
body: <p>I dunno if this is a valid question for this site, but I was wondering if someone experienced with the ContentNegotiatingViewResolver could look this over and let me know if I set it up correctly and well as help me send 404 messages.</p>
  
  <p>What I'd like to do is make all urls with no extension default to the HTML representation (which is freemarker views in my case). I'd like to accept urls with ".json" appended to them to render json instead. This appears to work in firefox, ie and chrome. I'm guessing it works in other browsers? I made sure to disable the accept header because it's an evil feature that doesn't really work like the documentation says it does.</p>
  
  <p>I have tried to access urls with ".stuff", just to see what happens, and with my configuration, a blank screen happens. Is this acceptable? Is there any way I can send a 404 error?</p>
  
  <p>Is there anything else that I may have not configured properly?</p>
  
  <pre><code>&lt;bean id="contentNegotiatingViewResolver"
        class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
      &lt;property name="order" value="1"/&gt;
      &lt;property name="ignoreAcceptHeader" value="true" /&gt;
      &lt;property name="defaultContentType" value="text/html" /&gt;
      &lt;property name="mediaTypes"&gt;
          &lt;map&gt;
              &lt;entry key="json" value="application/json"/&gt;
          &lt;/map&gt;
      &lt;/property&gt;
      &lt;property name="useNotAcceptableStatusCode" value="true" /&gt;
      &lt;property name="defaultViews"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"&gt;
                  &lt;property name="contentType" value="application/json" /&gt;
              &lt;/bean&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="viewResolvers"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"&gt;
                  &lt;property name="contentType" value="text/html" /&gt;
                  &lt;property name="order" value="2"/&gt;
                  &lt;property name="cache" value="true"/&gt;
                  &lt;property name="prefix" value=""/&gt;
                  &lt;property name="suffix" value=".ftl"/&gt;
                  &lt;property name="exposeSpringMacroHelpers" value="true"/&gt;
              &lt;/bean&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>