title: Switch between JSON (Jackson processor) and XML (XStream) or can i use it simultaneously?
body: <p>I'm trying to build an Web-Server which can serialize an Object into JSON and XML. Since I've integrated Jackson (using an example-Project) I'm able to access an JSON-Serialized Object via my REST Interface, but i'd like to get XML too.</p>
  
  <p>this...</p>
  
  <pre><code>@Controller
  @RequestMapping("/main/ajax")
  public class AjaxController {
  
  @RequestMapping(value = "/blah", method = RequestMethod.GET, headers = "Accept=application/xml")
  public @ResponseBody List&lt;String&gt; blah(@RequestParam(value="input") String input){
  
              List&lt;String&gt; stringList = new LinkedList&lt;String&gt;();
              stringList.add("i");
              stringList.add("am");
              stringList.add("an");
              stringList.add("json object");
              stringList.add(input);
  
              return stringList;
      }
   }
  </code></pre>
  
  <p>whit this query:</p>
  
  <pre><code>http://localhost:8080/spring-json/krams/main/ajax/blah?input=foobar
  </code></pre>
  
  <p>produces that output:</p>
  
  <pre><code>["i","am","an","json object","foobar"]
  </code></pre>
  
  <p>Any hints?</p>
  
  <p>UPDATE #1: I implemented the ContentNegotiatingViewResolver...</p>
  
  <pre><code>&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;!-- XML View --&gt; 
        &lt;bean class="org.springframework.web.servlet.view.xml.MarshallingView"&gt;
           &lt;constructor-arg&gt;
            &lt;bean class="org.springframework.oxm.xstream.XStreamMarshaller" /&gt;
          &lt;/constructor-arg&gt;
        &lt;/bean&gt;  
  
      &lt;/list&gt;
    &lt;/property&gt;
  
    &lt;property name="ignoreAcceptHeader" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- If no extension matched, use JSP view --&gt;
  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
    &lt;property name="order" value="2" /&gt;
    &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
    &lt;property name="suffix" value=".jsp"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>How do i now select either XML or JSON?
          localhost:8080/spring-json/sometestclass/status  ?
          localhost:8080/spring-json/sometestclass/status.xml  ?
          localhost:8080/spring-json/sometestclass/status.json ?</p>
  
  <p>None of the examples above are working, but i can force the response-format with the Accept-header "application/xml" or "application/json" ... if i do the following...</p>
  
  <pre><code>@RequestMapping(value = "/status", method = RequestMethod.GET, headers = "Accept=application/xml, application/json")
  public @ResponseBody Web_ServerStatus isServerAlive() {
      Web_ServerStatus l_ReturnObj = new Web_ServerStatus();
  </code></pre>
  
  <p>...i only get XML back.</p>
  
  <p>What's the problem i am running into?</p>
  
  <p>Thanks in advance!</p>