private String postHttpRequest(String objStr,String url){ HttpClient client = new DefaultHttpClient(); String bodyStr = ""; HttpPost httpPost = new HttpPost(url); try { StringEntity reqEntity = new StringEntity(objStr); //组装请求数据 httpPost.setEntity(reqEntity); } catch (Exception e) { log.error("postHttpRequest get entity error", e); return bodyStr; } try { HttpResponse response = client.execute(httpPost); //发送请求 HttpEntity entity = response.getEntity(); bodyStr = EntityUtils.toString(entity); //得到结果内容 }catch (Exception e) { log.error("postHttpRequest execute post error", e); return bodyStr; } log.info("bodyStr : " + bodyStr); return bodyStr; }
Httpclient POST
猜你喜欢
转载自even-ing.iteye.com/blog/2287697
今日推荐
周排行