解决cxf中list中对象为1个时返回json串问题的配置文件

来源:互联网 发布:人工智能假肢技术 编辑:程序博客网 时间:2024/06/06 02:20
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:jaxrs="http://cxf.apache.org/jaxrs"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util.xsdhttp://cxf.apache.org/jaxrshttp://cxf.apache.org/schemas/jaxrs.xsdhttp://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"><import resource="classpath:META-INF/cxf/cxf.xml" /><import resource="classpath:META-INF/cxf/cxf-servlet.xml" /><import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /><util:list id="jsonKeys"><value>app</value><value>comment</value></util:list><util:list id="jsonTypes"><value>application/json</value><value>application/jettison</value></util:list><bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider"><property name="arrayKeys" ref="jsonKeys" /><property name="serializeAsArray" value="true" /><property name="produceMediaTypes" ref="jsonTypes" /><property name="consumeMediaTypes" ref="jsonTypes" /></bean><jaxrs:server id="commonsService" address="/"><jaxrs:extensionMappings><entry key="json" value="application/json" /><entry key="xml" value="application/xml" /></jaxrs:extensionMappings><jaxrs:serviceBeans><ref bean="commentsServiceImpl" /><ref bean="userServiceImpl" /><ref bean="postServiceImpl" /><ref bean="contentRestImpl" /><ref bean="collectListRestImpl" /><ref bean="downloadListRestImpl" /><ref bean="rankServiceRestImpl" /><ref bean="appAddImpl" /><ref bean="appPush" /></jaxrs:serviceBeans><jaxrs:providers><ref bean="jsonProvider" /></jaxrs:providers></jaxrs:server></beans>


详情请参照网友hdxiong的博客:http://hdxiong.iteye.com/blog/1752036


从他那里找到的答案,谢谢~~~

原创粉丝点击