public static String doPost(String url, Map<String, String> header, Map<String, String> param)
            throws KeyManagementException, NoSuchAlgorithmException, IOException {

        String result = null;
        HttpClient httpClient = new SSLClient();
        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Constant.DEFAULT_CONN_TIMEOUT);
        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, Constant.DEFAULT_READ_TIMEOUT);
        HttpPost httpPost = new HttpPost(url);
        // 设置Header
        if (header != null) {
            Set<String> keys = header.keySet();
            for (String key : keys) httpPost.setHeader(key, header.get(key));
        }
        //设置参数
        List<NameValuePair> list = new ArrayList<NameValuePair>();
        Iterator iterator = param.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, String> elem = (Entry<String, String>) iterator.next();
            list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
        }
        if (list.size() > 0) {
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, Constant.DEFAULT_CHARSET);
            httpPost.setEntity(entity);
        }
        HttpResponse response = httpClient.execute(httpPost);
        if (response != null) {
            HttpEntity resEntity = response.getEntity();
            if (resEntity != null) {
                result = EntityUtils.toString(resEntity, Constant.DEFAULT_CHARSET);
            }
        }
        return result;
    }
public static String doPost ( String url , Map < String , String > header , Map < String , String > param ) throws KeyManagementException , NoSuchAlgorithmException , IOException { String result = null ; HttpClient httpClient = new SSLClient ( ) ; httpClient . getParams ( ) . setParameter ( CoreConnectionPNames . CONNECTION_TIMEOUT , Constant . DEFAULT_CONN_TIMEOUT ) ; httpClient . getParams ( ) . setParameter ( CoreConnectionPNames . SO_TIMEOUT , Constant . DEFAULT_READ_TIMEOUT ) ; HttpPost httpPost = new HttpPost ( url ) ; if ( header != null ) { Set < String > keys = header . keySet ( ) ; for ( String key : keys ) httpPost . setHeader ( key , header . get ( key ) ) ; } List < NameValuePair > list = new ArrayList < NameValuePair > ( ) ; Iterator iterator = param . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Entry < String , String > elem = ( Entry < String , String > ) iterator . next ( ) ; list . add ( new BasicNameValuePair ( elem . getKey ( ) , elem . getValue ( ) ) ) ; } if ( list . size ( ) > 0 ) { UrlEncodedFormEntity entity = new UrlEncodedFormEntity ( list , Constant . DEFAULT_CHARSET ) ; httpPost . setEntity ( entity ) ; } HttpResponse response = httpClient . execute ( httpPost ) ; if ( response != null ) { HttpEntity resEntity = response . getEntity ( ) ; if ( resEntity != null ) { result = EntityUtils . toString ( resEntity , Constant . DEFAULT_CHARSET ) ; } } return result ; }
POST方式向Http(s)提交数据并获取返回结果

@param url    URL
@param header Header
@param param  参数（Map）

@return 获取服务器数据

@throws KeyManagementException [ellipsis]
@throws NoSuchAlgorithmException [ellipsis]
@throws IOException [ellipsis]