HttpClient使用post方式模拟表单提交数据

//组装url
        String url = "http://192.168.0.105:8080/";
        // 创建httpClient
        CloseableHttpClient httpClient = HttpClients.createDefault();
        // 创建post请求方式实例
        HttpPost httpPost = new HttpPost(url);
        Listlist = new ArrayList();
        list.add(new BasicNameValuePair("tableName",tableName));
        list.add(new BasicNameValuePair("fileName",fileName));
        list.add(new BasicNameValuePair("path",path));
        HttpEntity entity = new UrlEncodedFormEntity(list);//模拟form进行表单提交
        httpPost.setEntity(entity);                               //banding内容
        HttpResponse response = httpClient.execute(httpPost); //连接服务器
        HttpEntity entit =  response.getEntity(); //获取内容
        return EntityUtils.toString(entit, "utf-8");