title: unable to use @ResponseBody to send json object in spring mvc
body: <p>Upon trying to get my response in JSON using Spring 4.x, 
  I get the 406 error :</p>
  
  <p><strong>"The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ()."</strong></p>
  
  <p>Here is my environment:</p>
  
  <pre><code>* Spring 4.1.6.RELEASE
  * included jackson-all-1.9.0.jar
  * Tomcat 6.x
  * mvc:annotation-driven in Spring configuration XML file
  </code></pre>
  
  <p><strong>My Controller:</strong></p>
  
  <pre><code>@RequestMapping(value = "/getAllStudents", method = RequestMethod.GET,produces="application/json")
  @ResponseBody
  public List&lt;Student&gt; getAllExpenses() {
      List&lt;Student&gt; students= studentDaoImp.getStudents();
      return students;
      //return new JsonJtableResponse().ok(students);
  }
  </code></pre>
  
  <p><strong>My Spring Configuration file:</strong></p>
  
  <pre><code>    &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
     http://www.springframework.org/schema/beans     
     http://www.springframework.org/schema/beans/spring-beans.xsd
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd
     http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  
  
      &lt;!-- telling container to take care of annotations stuff --&gt;
      &lt;context:annotation-config /&gt;
  
      &lt;!-- declaring base package --&gt;
      &lt;context:component-scan base-package="com.controller" /&gt;
      &lt;context:component-scan base-package="com" /&gt;
      &lt;mvc:annotation-driven /&gt;
      &lt;!-- &lt;mvc:resources location="/css/" mapping="/css/**" /&gt; --&gt;
      &lt;mvc:resources mapping="/**" location="/" /&gt;
  
  
      &lt;bean
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
  
  
      &lt;!-- declare datasource bean --&gt;
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /&gt;
          &lt;property name="url"
              value="jdbc:sqlserver://localhost:1433;databaseName=Test;instancename=mssqlserver1;" /&gt;
          &lt;property name="username" value="sa" /&gt;
          &lt;property name="password" value="abc123" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="StudentDao" class="com.dao.StudentDaoImp"&gt;
          &lt;constructor-arg ref="dataSource" /&gt;
      &lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Appreciate any help in this regard.</p>