比如这个util每次调用doGet时生成一个httpClient实例publicstaticStringdoGet(Stringurl,Mapparam){ //创建Httpclient对象CloseableHttpClienthttpClient=HttpClients.createDefault();难道不可以在这个util类中加httpClient的静态实例成员吗,所有doGET,doPost调用都用同一个httpClient的静态实例成员,如下publicclassHttpClientUtil{privatestaticCloseableHttpClienthttpClient=HttpClients.createDefault();publicstaticStringdoGet(Stringurl,Mapparam){ ....response=httpClient.execute(httpGet);
暮色呼如
相关分类