Java моделирует запросы на отправку HTTP. Первый - это httpurlconnection Отправка запросов. Второе - использовать httppclient для имитации запросов POST.
Пример кода:
Пакет Тест; импорт java.util.arraylist; import java.util.hashmap; import java.util.list; import java.util.map; import java.util.map.entry; импорт java.util.concurrent.executorservice; импорт java.util.concurrent.executors; org.apache.http.httpentity; import org.apache.http.namevaluepair; import org.apache.http.client.config.requestconfig; импорт org.apache.http.client.Entity.urlencodedForty; импорт org.apache.http.client.methods.closablehttpresponse; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.closablehtpclient; import org.apache.http.impl.client.httpclient; import org.apache.http.impl.client.httpclient; import org.apache.http.impl.client.httpclient; org.apache.http.message.basicnamevaluepair; import org.apache.http.util.entityutils;/** Java Simulation Test Multiethreaded Test http refsure*@author wdh**/public class parameStest upretrable {private StringStReptStest (Obstring> STRIPTRESTESTESTESTESTESTESTEST (Private StringStest (ObsiteRyStest SpulseSteStest (Private StringStest; url, map <string, object> paramstr) {super (); this.url = url; this.paramstr = paramstr;} public String getUrl () {return url;} public void seturl (string url) {this.url = url;} public map <string> getParamStr () {return ParamStr;} void void stepparpAram string (object> getParam {this.paramstr = paramstr;}@overridepublic void run () {// http -запрос метод реализации oblesablehttpclient httpclient = httpclients.createdefault (); httppost post = new httppost (url); RequestConfig.custom (). SetConnectionRequestTimeout (10000) .setConnecttimeout (10000) .setSockettimeout (10000) .build (); Qualeablehttpresponse response = null; try {list <namevaluepair> params = sethttpnamevalues (paramstry); Httpentity httpentity = new urlencodedformentity (params, "utf-8"); post.setentity (httpentity); post.setConfig (config); outs = httpclient.execute (post); httpentity entity = response.getentity (); String Content = String Content = String = String = String = String = String = String = String = String = String = String = String = String = String = String = String = String. EntityUtils.toString (entity); System.out.println ("Content:" + Content);} Catch (Exception e) {e.printStackTrace ();}} частный список <namevalueepair> sethttpnamevalues (map <string> parammap) {listValUeepair> rateep <Stame> (объект> parammap) {namevalueepair>; for (entry <string, object> intpirt: parammap.entryset ()) {params.add (new basicnamevaluepair (entry.getkey (), entry.getValue (). toString ())); } return params;} public static void main (string [] args) {// Использовать пул потоков в классе Java Tool Classervice Pool = Executors.newcachedThreadpool (); for (int i = 0; i <2; i ++) {// Открыть два потока string url = "xxxx"; ServiceThreadTest (url, paramstr));}} public Static Map <String, Object> gethttpparamstr () {map <string, object> param = new hashmap <string, object> (); param.put ("apiversion", 1); param.put ("appversion", "3.6.2");Выше всего, что содержится, обмениваемым о многопоточных HTTP-запросах Java. Спасибо за поддержку Wulin.com.