publicstatichttpresultpostjsondata (字符串URL、映射、字符串参数、字符串图表) throws Exception{
closeablehttpclienthttpclient=http client util.create default (;
http post http post=new http post (URL;
//连接参数
listnamevaluepairlist=newarraylistnamevaluepair (;
for(map.entrystring,stringentry : params.entryset () () () ) ) ) )。
String key=entry.getKey ().toString );
String value=entry.getValue ().toString );
//System.out.println (响应内容为1: ) httpentity.getcontent );
}
字符串结果=null;
try {
result=entity utils.tostring (http entity,DEFAULT_CHARSET );
Logger.info(result );
}catch(ioexceptione ) {
throw e;
} finally {
实体utils.consume (http entity );
}
returnJSON.parseobject(result,HttpResult.class );
//return httpEntity.getContent (;
}else{
返回空值;
}
}catch(ioexceptione ) {
thrownewexception(e.getmessage ) );
}finally {
try{
//释放资源
响应!=空) {
response.close (;
}
if(http客户端!=空) {
http客户端. close (;
}
}catch(ioexceptionE1) {
throw new exception (closeablehttpresponsecloseexception );
}
}
}