我们的 Spring 3.1 应用程序以下列方式使用消息转换器:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
....
....
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="writeAcceptCharset" value="false"/>
</bean>
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter"/>
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
<bean class="org.springframework.http.converter.feed.AtomFeedHttpMessageConverter"/>
</list>
</property>
</bean>
<bean class="org.codehaus.jackson.map.ObjectMapper" name="objectMapper"/>
在我的一个控制器中,我有一个 RequestMapping :
@RequestMapping(value = "pathFoo", produces = MediaType.APPLICATION_ATOM_XML_VALUE)
public @ResponseBody Feed getFooAtomXML(HttpServletRequest request, HttpServletResponse response){
但似乎除非我指定请求标头 Accept=application/atom+xml,否则响应会以 JSON 而不是 XML 的形式返回。无论请求标头是否存在,如何配置应用程序以便在此映射中使用 AtomFeedHttpMessageConverter?
我需要依赖 ViewResolver 吗?