java - 邮递员“状态”:415,“错误”:“不支持的媒体类型”,
问题描述
我试图创建一个类,我可以在其中将客户(客户)添加到类(aula)
@RequestMapping(value = "/aulas/{numero}/{numerocliente}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<Object> addClienteAula(@PathVariable("numero") int nraula, @PathVariable("numerocliente") int nrclente) {
try {
AulaService.addAlunoAula(nraula, nrclente);
return new ResponseEntity<>(HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>(new ErroDTO(e), HttpStatus.CONFLICT);
}
}
这是我对邮递员的要求:
http://localhost:8080/api/aulas/1/23
结果是这样的:
{
"timestamp": "2020-04-25T00:12:02.300+0000",
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'text/plain' not supported",
"path": "/api/aulas/1/23"
}
解决方案
在邮递员的请求标头中提及您的内容类型
Content-Type application/xml
推荐阅读
- java - 在没有 gradle、maven 或 IDE 的情况下使用 MongoDB 和 Java
- python - 将 NER 训练数据转换为 Spacy 训练数据格式
- snmp - phpipam SNMP 代理端配置
- linux - pm2 log-rotate with ansible
- office-js - Office 加载项 Excel:选择范围并能够像函数参数一样调整选择的大小
- c# - WPF - 使用 TwoWay 模式将枚举绑定到 DatagridComboBoxColumn
- rest - 仅当 X-Auth-Token 相同时才对经过身份验证的 REST api 请求进行 HTTP 缓存
- excel - IF 和 For 循环中的 VBA For 循环
- azure - 为什么我无法导航到 Azure 应用服务中的静态 Html 页面?
- python - 如何在 django-filter 中为 DateFromToRangeFilter 设置默认查询集?