This article uses httpcomponents-client-4.4.1 formerly known as HTTP client
When sending post data, the data is typically UrlEncode transcoded---urlencode or urlencodedformentity.
The following items are used to set the HTTP request header encoding or request content properties, specifically please Baidu.
//. AddHeader ("Accept-charset", "Utf-8")//fail
. AddHeader ("Content-type", "Text/plain;charset=utf-8")//fail
. AddHeader ("Content-type", "application/x-www-form-urlencoded")
Static void t3 () {Stringbuffer mobiles = new stringbuffer () .append (" 13581xxxxxx "). Append (", ") .append (" 18669xxxxxx "). Append (", ") .append (" 13121xxxxxx "). Append (", ") .append ("18210xxxxxx"). Append (",") .append ("15811xxxxxx"). Append (",") .append ("15331xxxxxx"). Append (",") .append ("18501xxxxxx"). Append (",") .append ("13699xxxxxx"). Append (",") .append (" 18500xxxxxx "). Append (", ") .append (" 18310xxxxxx "). Append (", ") .append (" 13581xxxxxx "); string msg = "Hello staff, thank you for your cooperation in this test. "; List<namevaluepair> ls = new arraylist<> (); Ls.add (New BasicNameValuePair ( "UserId", "jxxxx"), Ls.add (New basicnamevaluepair ("Password", "5xxx3"); Ls.add (new Basicnamevaluepair ("Mobis", mobiles.tostring ())); Ls.add (New basicnamevaluepair ("msg", msg)); Ls.add (New basicnamevaluepair ("Mobicount", " + 11"); Ls.add (New basicnamevaluepair (" AubporT ", ")), Ls.add (New basicnamevaluepair ("MsgId", "98xxxx31")); try {httpentity entity = request.post ("Http://61.1xx.xxx.29:xxxx/Mxxx/wxxx.axxx/MxxxxxSubmit"). ConnectTimeout. Body ( New urlencodedformentity (LS, "UTF-8")). Execute (). Returnresponse (). GetEntity (); Entity.writeto (System.out);} catch (exception e) {e.printstacktrace ();}}
HttpClient POST Request