title: When/where is it ideal to determine Unsupported Media Type in Spring?
body: <p>So, I have a Spring MVC application, and I want a way to determine when a resource doesn't support a specific media type.  I was thinking of doing this with custom View Resolvers...  If none of the view resolvers find a successful match for the view name, then throw an exception triggering Unsupported media type (HTTP code of <code>406</code>).  </p>
  
  <p>This mostly makes sense because most view resolvers will return <code>null</code> if it can't resolve the given view name.  The problem arises with view resolvers like <code>InternalResourceViewResolver</code> which ALWAYS returns a view, even if the given view name doesn't exist.  </p>
  
  <p>Just as a reference, here is what my controllers look like:</p>
  
  <pre><code>@RequestMapping(value = "/viewTest", method = RequestMethod.GET)
  public ModelAndView getViewData() {
  
      Map&lt;String, Object&gt; myModel = new HashMap&lt;String, Object&gt;();
      myModel.put("rightNow", (new Date()).toString());
  
      return new ModelAndView("foo", "model", myModel);
  }
  </code></pre>
  
  <p>Thanks!</p>