java - Jetty 服务器中的 HTTP 415 不支持的媒体类型
问题描述
我有以下端点
@Path("endpoint")
public class MyEndPoint {
@POST
@Path("{paramA}/{paramB}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public void trackPOST(@PathParam("paramA") String paramA, @PathParam("paramB") String paramB,
@Context HttpHeaders httpHeaders,
@Context HttpServletRequest request, @Context UriInfo uriInfo,
@RequestBody Model data,
@Suspended AsyncResponse asyncResponse) {
}
我正在对路径进行发布请求/endpoint/paramAValue/paramBValue
具有与该类匹配的 Json Body Model
(仅String
具有 setter 和 getter 的属性)
并带有标题Content-Type: application/json;
我从我的 Rest 客户端收到以下错误
{
"code": 415,
"error": "HTTP 415 Unsupported Media Type"
}
我错过了什么?
解决方案
推荐阅读
- python - 程序在Python上的错误操作,计算两个数之和
- c++ - 如何从向量中的 args 调用函数?
- compiler-construction - 预期错误;在使用 bison 和 flex 休息之前
- virtualbox - 无法连接数据库:Mongoose/MongoDB,虚拟盒子
- python - 从 OneHotEncoder 获取相应的特征
- swift - Vapor join 和 alsoDecode 产生大量嵌套元组
- vue.js - Vue 不显示传递给子 vue 的参数
- ios - IOS:强制 tableView 单元格在点击时动画更改
- javascript - NPM 包 - 将信息传递给消费者
- python - 我可以在 python 中有多个构造函数并覆盖 __str__ 方法吗