String result = HttpUtil.doPost(this.productPriceUrl,JSON.toJSONString(tLisJcPriceVo));
/**
* post请求
* @param url
* @param json
* @return
*/
public static String doPost(String url,String json){
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
JSONObject response = null;
try {
if(null != json) {
//解决中文问题。
post.addHeader("Content-type","application/json; charset=utf-8");
post.setHeader("Accept", "application/json");
post.setEntity(new StringEntity(json.toString(), Charset.forName("UTF-8")));
}
HttpResponse res = client.execute(post);
if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
HttpEntity entity = res.getEntity();
String result = EntityUtils.toString(res.getEntity());// 返回json格式:
return result;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}