java Fegin x-www-form-urlencoded 类型请求

spring发送 content-type=application/x-www-form-urlencoded 和普通请求不太一样。

@FeignClient(
    name = "ocr-api",
    url = "${orc.idcard-url}",
    fallbackFactory = OcrClientFallbackFactory.class
)
public interface OcrClient {
 
    @PostMapping(
        value = "/v1/demo/idcard",
        headers = {"content-type=application/x-www-form-urlencoded"}
    )
    OcrBaseResponse<IdCardResponse> getIdCarInfo(@RequestBody MultiValueMap<String, Object> request);
}

其他方式比如: application/json;charset=UTF-8 可以  OcrBaseResponse<IdCardResponse> getIdCarInfo(@RequestBody Map<String, String> request);

但是  content-type=application/x-www-form-urlencoded 的就得用 MultiValueMap

 

posted @ 2023-07-11 16:03  study_php_java_C++  阅读(509)  评论(0编辑  收藏  举报