本文介绍了摇摇欲坠的注释内容类型未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个弹簧支架控制器:
I have this spring rest controller:
@RestController
@RequestMapping("/communications")
class CommunicationController(private val service: CommunicationService) {
@ApiOperation(
produces = APPLICATION_JSON_VALUE,
consumes = APPLICATION_JSON_VALUE
)
@GetMapping(
consumes = [APPLICATION_JSON_VALUE],
produces = [APPLICATION_JSON_VALUE]
)
fun findAll(
criterias: CommunicationCriterias,
page: Pageable
): List<CommunicationDTO> = service.findCommunications(criterias, page)
}
当我通过swagger-ui
(springfox)接口测试此端点时,出现了415: content type invalid
错误.似乎标头中未设置content-type: application/json
.
When I test this endpoint via the swagger-ui
(springfox) interface, i got a 415: content type invalid
error. It seems that content-type: application/json
is not set in the header.
缺少什么?
推荐答案
HTTP GET请求中没有消耗.我认为您应该从@GetMapping
和@ApiOperation
中删除consumes
.
There is nothing to consume in HTTP GET request. I think you should remove the consumes
from @GetMapping
and @ApiOperation
.
这篇关于摇摇欲坠的注释内容类型未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!