您的位置:首页 > Web前端 > JavaScript

JAX-RS 如何传输 JSON 格式的数据 ?

2017-09-01 10:37 302 查看
客户端中查询某个用户,获取json时报错

错误内容:
Caused by: javax.ws.rs.ProcessingException: No message body writer has been found for class cn.itcast.cxf.domain.User, ContentType: application/json


解决方法: 在pom.xml中引入两个坐标

<!-- 在CXF扩展提供者,提供转换json接口  -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
<version>3.0.1</version>
</dependency>

<!-- cxf 扩展提供者 转换json 默认需求一个工具包  -->
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.7</version>
</dependency>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: