Feign的post请求参数设置

feign的post和get请求
之前写的一篇博文,这次发现有个小问题,修改了,顺便把测试用例粘贴上来。
controller的方法:

	@PostMapping("/testPost")
    public TModel<?> testReward(@RequestBody JSONObject body){
        System.out.println("done");
        System.out.println(body.toJSONString());
        return TModel.success();
    }

调用测试的四种方法:

public interface TestClient {
    @RequestLine("POST /testPost")
    JSONObject postTestFirst(@RequestBody Map<String,Object> params);

    @RequestLine("POST /testPost")
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    JSONObject postTestSecond(@RequestBody Map<String,Object> params);

    @RequestLine("POST /testPost")
    JSONObject postTestThird(@QueryMap Map<String,Object> params);

    @RequestLine("POST /testPost")
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    JSONObject postTestFourth(@QueryMap Map<String,Object> params);
}

第一个接口报错信息如下:

URL:/testPost error status:500
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported

第二个接口成功;
第三个接口报错:

URL:/testPost error status:500
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing

第四个接口也报错:

URL:/testPost error status:500
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported

你可能感兴趣的:(java,web开发,post,java,json)