String url = "http://localhost:831/ruoyi/ecr/productinfo/findByFldOrderCode";
String charset = "UTF-8";
JSONObject jsonObject = new JSONObject();
jsonObject.put("fldOrderCode","2022-JM-Q104");
jsonObject.put("fldReUnid","string");
jsonObject.put("pageNum",1);
jsonObject.put("pageSize",10);
String content = jsonObject.toJSONString();
CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", "application/json;charset=UTF-8");
StringEntity se = null;
try {
se = new StringEntity(content);
se.setContentEncoding(charset);
se.setContentType("application/json");
post.setEntity(se);
CloseableHttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
String resData = EntityUtils.toString(response.getEntity());
System.out.println(resData);
client.close();
} catch (Exception e) {
e.printStackTrace();
}
|