欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

ajaxpost帶參數請求后臺怎么接收參數

錢良釵2年前20瀏覽0評論

ajaxpost帶參數請求后臺怎么接收參數?

把要發送的json作為字符串傳入body即可public static String sendHttpPost(String url, String body) throws Exception { closeableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Content-Type", "application/json"); httpPost.setEntity(new StringEntity(body)); CloseableHttpResponse response = httpClient.execute(httpPost); System.out.println(response.getStatusLine().getStatusCode() + "\n");

HttpEntity entity = response.getEntity(); String responseContent = EntityUtils.toString(entity, "UTF-8"); System.out.println(responseContent);

response.close(); httpClient.close(); return responseContent; }