entity를 통해 HttpClient 데이터 업로드
1126 단어 httpclient
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(url);
byte[] b =json.toString().getBytes();
RequestEntity entity = new ByteArrayRequestEntity(b);
post.setRequestEntity(entity);
post.setRequestHeader("Content-Type", "application/octet-stream");
int code = client.executeMethod(post);
String result=post.getResponseBodyAsString();
혹은
DefaultHttpClient httpClient=new DefaultHttpClient();
HttpEntity httpEntity = new StringEntity(iq.toXML(), "UTF-8");
HttpPost httpPost = new HttpPost("http://******:7080/channel/send");
httpPost.setEntity(httpEntity);
HttpResponse response = httpClient.execute(httpPost);
InputStream is = response.getEntity().getContent();
BufferedReader in = new BufferedReader(new InputStreamReader(is));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = in.readLine()) != null) {
buffer.append(line);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
HttpClient 'GET' - 각도 단순화이봐, 친구들. 오늘 저는 API를 호출하는 Angular의 방법을 분석하고 싶습니다. 각 CRUD 작업에 대한 기사를 작성할 예정이므로 눈을 떼지 말고 팔로우하십시오! 이것이 기본이며 Angular 웹 사이트에서 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.