HttpCliend
HttpPost
HttpResponse
HttpEntity
NameValuePair
공부해야게따ㅠㅠ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://localhost:8080/testLatLngData"); httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); List<NameValuePair> testParam = new ArrayList<>(); testParam.add(new BasicNameValuePair("lat", ( "37.469997210138416" ))); testParam.add(new BasicNameValuePair("lng", ( "126.9273415126953" ))); httpPost.setEntity(new UrlEncodedFormEntity(testParam, "UTF-8")); HttpResponse resp = httpClient.execute(httpPost); HttpEntity respEntity = resp.getEntity(); Object obj = JSONValue.parse(new InputStreamReader(respEntity.getContent())); //결과처리 //JSONObject jsonObject = (JSONObject) obj; | cs |
'1.자바 > Java' 카테고리의 다른 글
이미지 URL 바이트 쓰기 (0) | 2016.10.26 |
---|---|
Java 콤마를 구분하여 배열에 담기 (0) | 2016.09.01 |
MultiValueMap, RestTemplate, HttpEntity 이용하기 (0) | 2016.08.12 |
자바 AES 256 암호화 복호화 (4) | 2016.08.09 |
API 작성을 도와주는 Javadoc (0) | 2016.07.06 |