Take Jsoup as an example, x-www-form-urlencoded way
map<string,object> Map = new hashmap<> (); Map.put ("state", 1); Map.put ("sentence", "with the new energy car subsidy policy 2018 years before the Spring Festival, the lithium cobalt plate ushered in a start after the holiday, a number of companies have announced in the field of lithium cobalt new layout." In the evening of February 25, the new sea (market 002089, the Consultation unit) announced the signing of the lithium industry Cooperation agreement, a further contribution of 500 million with the National Australia Fund cooperation; Soft holding (market 002073, consultation unit) also announced the proposed subscription of Ecobalt shares, the layout of lithium battery core mineral resources; Peng Yan Resources (market 600490, ) in the Congo (Gold), the subsidiary of the DRC and the local mining company signed a copper-cobalt concentrate underwriting agreement, strengthen the copper and cobalt Resources reserve ");D ocument doc = jsoup.connect (" Localhost:10884/api/klg/textdemo/all ") . Header ("useragent", "mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/65.0.3325.181 safari/537.36 "). Header (" Content-typ E "," Application/x-www-form-urlencoded;charset=utf-8 "). Data (" state "," 1 "). Data (" Sen Tence "," with the new energy car subsidy policy of 2018 years before the Spring Festival, the lithium-cobalt plate ushered in a start after the holiday, a number of companies have announced in the field of lithium cobalt new layout. In the evening of February 25, the new sea (market 002089, the Consultation unit) announced the signing of the lithium industry Cooperation agreement, a further contribution of 500 million with the National Australia Fund cooperation; Soft holding (market 002073, consultation unit) also announced the proposed subscription of Ecobalt shares, the layout of lithium battery core mineral resources; Peng Yan Resources (market 600490, In the Congo (Gold), the subsidiary of the DRC has signed a copper-cobalt concentrate underwriting agreement with the local mining company to strengthen the copper-cobalt resource Reserve "). Post ();
Application/json Way
ma<string,string> map = new hashmap<> (), Map.put ("username", "AAAA"), Map.put ("Password", "123456"); Gson Gson = new Gson (); String parameter = Gson.tojson (map);D ocument doc = jsoup.connect ("Localhost:8080/api/user/login") . Header (" UserAgent "," mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/65.0.3325.181 safari/537.36 ") . Requestbody (parameter) . Ignorecontenttype (True) . Post ();
How to access network resources--application/json and x-www-form-urlencoded