public static Jsonobject Sendpost (jsonobject jsonparam, String url) {logger.info ("Get Receipt Information Request parameter:" +jsonparam.tostring ()); Jsonobject Resultjson = null;//Create HttpClient object Closeablehttpclient client = Httpclients.createdefault (); Create Post method Request Object HttpPost HttpPost = new HttpPost (URL); Stringentity Entity=null; if (Jsonparam! = null) {entity = new stringentity (jsonparam.tostring (), "utf-8");//Solve Chinese garbled problem} Entity.setcontentencoding ("UTF-8"); Entity.setcontenttype ("Application/json"); Httppost.setentity (entity); Originating request HttpResponse HttpResponse = null; String Resdata = null;try {HttpResponse = Client.execute (httppost); resdata = Entityutils.tostring ( Httpresponse.getentity (), Charsets.UTF_8.name ());} catch (IOException e) {logger.error (E.getmessage (), e);} finally {try {client.close ()} catch (IOException e) {Logger.err or (E.getmessage (), E);}} Resultjson = Json.parseobject (resdata); return Resultjson;}
Send HttpPost Request