title: json response is not returned using spring 3.1
body: <p>I am trying to return json and xml response using ResponseBody, and it does work fine for xml but doesnt return json. My request uri for xml is '../home.xml' and for json is '../home.json' from controller method:</p>
  
  <pre><code>@RequestMapping("home.*")
  public  @ResponseBody Message homeOther(HttpServletRequest request, HttpServletResponse response, ModelMap mv){
      Message msg = new Message();
      msg.setDetail("I am here at home");
      msg.setUploadDate(new Date());
  
      mv.addAttribute("message", msg);
  
      return msg;
  }
  </code></pre>
  
  <p>And here is the dispatcher servlet:</p>
  
  <pre><code>&lt;context:component-scan base-package="com.ym"/&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;
      &lt;property name="alwaysUseFullPath" value="true"/&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&gt;
      &lt;property name="resourceLoaderPath" value="/views"/&gt;
  &lt;/bean&gt;
  
  &lt;!-- Simple ViewResolver for Velocity, appending ".vm" to logical view names --&gt;
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"&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=".vm"/&gt;
      &lt;property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/&gt;
      &lt;!-- if you want to use the Spring Velocity macros, set this property to true --&gt;
      &lt;property name="exposeSpringMacroHelpers" value="true"/&gt;
      &lt;property name="contentType" value="text/html; charset=UTF-8" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" /&gt;
  
  
  &lt;bean id="xmlView" class="org.springframework.web.servlet.view.xml.MarshallingView"
        &gt;
        &lt;constructor-arg ref="xstreamMarshaller" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
      &lt;property name="messageConverters"&gt;
          &lt;list&gt;
              &lt;ref bean="jsonHttpMessageConverter" /&gt;
              &lt;ref bean="marshallingHttpMessageConverter" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;
      &lt;property name="supportedMediaTypes" value="application/json" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="marshallingHttpMessageConverter"
        class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"&gt;
      &lt;property name="marshaller" ref="xstreamMarshaller"/&gt;
      &lt;property name="unmarshaller" ref="xstreamMarshaller"/&gt;
  &lt;/bean&gt;
  
  
  
  &lt;bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
    &lt;property name="order" value="1" /&gt;
    &lt;property name="mediaTypes"&gt;
      &lt;map&gt;
         &lt;entry key="json" value="application/json" /&gt;
         &lt;entry key="xml" value="application/xml" /&gt;
      &lt;/map&gt;
    &lt;/property&gt;
  
    &lt;property name="defaultViews"&gt;
      &lt;list&gt;
        &lt;!-- JSON View --&gt;
        &lt;bean
          class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"&gt;
        &lt;/bean&gt;
  
        &lt;ref bean="xmlView" /&gt;
       &lt;/list&gt;
    &lt;/property&gt;
    &lt;property name="ignoreAcceptHeader" value="true" /&gt;
  
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here is XML response:</p>
  
  <pre><code>&lt;com.ym.mongodb.model.Message&gt;
   &lt;messageId&gt;0&lt;/messageId&gt;
   &lt;detail&gt;I am here at home&lt;/detail&gt;
   &lt;uploadDate&gt;2013-03-09 09:56:46.606 UTC&lt;/uploadDate&gt;
  &lt;/com.ym.mongodb.model.Message&gt;
  </code></pre>
  
  <p>My problems are:
  1. what is worng with the configuration? why it doesnt return a json response.?
  2. Why the xml it returns, display fullyqualified name of Message?
   i am using Spring 3.1.</p>
  
  <p><strong>Edit</strong>:
  Interestingly, it does create json n xml correctly when request type is set properly. But still the 2nd problem does exists.</p>