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

发布时间 2023-07-11 16:07:15作者: study_php_java

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