private static Logger log = Loggerfactory.getlogger (Httppostutil.class); public static string Reqxinyi (string url, string appkey,string data,string sign) throws ioexception{Objectmapper Ma
Pper = new Objectmapper ();
String param= null;
String B = null; try {param = "appkey=" + urlencoder.encode (Appkey, "UTF-8") + "&data=" +urlencoder.encode (data, "UTF-8") + "&si
gn= "+urlencoder.encode (sign," UTF-8 ");
Log.info ("Stitching request parameter param:" +param);
catch (Unsupportedencodingexception e) {log.error ("stitching request parameter Error");
E.printstacktrace ();
} log.info ("Start sending request");
URL url = new URL (URLs);
URLConnection connection = Url.openconnection ();
HttpURLConnection httpconn = (httpurlconnection) connection;
Set the request method to post Httpconn.setrequestmethod ("POST");
Sets whether the output Httpconn.setdooutput (true) is required;
Sets whether you want to allow input httpconn.setdoinput (true); Set request Properties Httpconn.setrequestproPerty ("Content-length", String.valueof (Param.getbytes (). Length));
Httpconn.setrequestproperty ("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
Write data to server outputstream out = Httpconn.getoutputstream ();
Out.write (Param.getbytes ("UTF-8"));
Out.close ();
The data returned by the receiving server InputStream in = Httpconn.getinputstream ();
Bytearrayoutputstream resp = new Bytearrayoutputstream ();
byte[] tempbytes = new byte[100];
int byteread = 0;
while ((Byteread = In.read (tempbytes))!=-1) {resp.write (tempbytes, 0, Byteread);
} B = New String (Resp.tobytearray ());
Log.info ("Call interface return: {}", b);
return b;
}