“status”:415

“error”:”Unsupported Media Type”

“exception”:”org.springframework.web.HttpMediaTypeNotSupportedException”

因为:没有运用JSON.stringify(rowData)本领将乞求参数变化为json字符串

报(Unsupported Media Type)特殊重要原由于,前者东西乞求接口的典型和后端效劳器设置的典型不普遍形成,

普遍东西乞求典型和后端维持普遍后,即可平常乞求。

因为:按照接口所传参数的各别,post乞求的Content-type有四种:

application/x-www-form-urlencoded(默许)

application/xml

application/json

multipart/form-data

我所对接的接口所传的参数是json方法的,代码中没有树立乞求头header的Content-Type,默许是application/x-www-form-urlencoded。

URIBuilder uriBuilder = new URIBuilder(url);

//创造一个http post乞求

HttpPost httpPost = new HttpPost(uriBuilder.build());

//树立乞求头header

httpPost.setHeader("Content-Type","application/json");

//树立乞求数据

httpPost.setEntity(new StringEntity(strJson,"utf-8"));