title: spring mvc not returning json content - error 406
body: <p>I am using Spring MVC with JSON as specified in <a href="http://blog.springsource.org/2010/01/25/ajax-simplifications-in-spring-3-0/" rel="noreferrer">Ajax Simplification Spring 3.0 article</a>.</p>
  
  <p>After so many attempts and variations of my code depending on advice found on various forums, my code still doesn't work.</p>
  
  <p>I keep on getting the following error: (406) The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().</p>
  
  <p>I have   in my appconfig.xml as required.</p>
  
  <p>app-config.xml</p>
  
  <pre><code>    &lt;context:component-scan base-package="org.ajaxjavadojo" /&gt;
  
      &lt;!-- Configures Spring MVC --&gt;
      &lt;import resource="mvc-config.xml" /&gt;
  </code></pre>
  
  <p>mvc-config.xml</p>
  
  <pre><code>&lt;mvc:annotation-driven /&gt;
  
  &lt;!-- Forwards requests to the "/" resource to the "index" view --&gt;
  &lt;mvc:view-controller path="/" view-name="index"/&gt;
  
  
  &lt;!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory --&gt;
  &lt;bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
  &lt;property name="mediaTypes"&gt;
  &lt;map&gt;
    &lt;entry key="html" value="text/html"/&gt;
    &lt;entry key="json" value="application/json"/&gt;
  &lt;/map&gt;
  &lt;/property&gt;
  &lt;property name="viewResolvers"&gt;
  &lt;list&gt;
    &lt;bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/&gt;
    &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix" value="/WEB-INF/views/"/&gt;
      &lt;property name="suffix" value=".jsp"/&gt;
    &lt;/bean&gt;
  &lt;/list&gt;
  &lt;/property&gt;
  
  &lt;/bean&gt;
  </code></pre>
  
  <p>This is what I have for my controller</p>
  
  <pre><code>@Controller
  @RequestMapping (value = "/convert")
  public class ConversionController {
  
    @RequestMapping(method=RequestMethod.GET)
    public String getConversionForm(){
      return "convertView";
    }
  
    @RequestMapping(value = "/working", headers="Accept=application/json", method=RequestMethod.GET)
    public @ResponseBody Conversion getConversion(){
      Conversion d = new Conversion("d");
      return d;
    }
  }
  </code></pre>
  
  <p>jsp jquery call</p>
  
  <pre><code>  function convertToDecimal(){
      $.getJSON("convert/working", {key: "r"}, function(aConversion){
        alert("it worked.");
        $('#decimal').val(aConversion.input);
      });
    }
  </code></pre>
  
  <p>I would really appreciate any input on this issue. 
  Thank you</p>