ication/octet-stream"); httpConn.setRequestProperty("Connection", "Keep-Alive");// 维持长连接 httpConn.setRequestProperty("Charset", "UTF-8"); String name=URLEncoder.encode("黄武艺","utf-8"); httpConn.setRequestProperty("NAME", name); //建立输出流,并写入数据 OutputStream outputStream = httpConn.getOutputStream(); outputStream.write(requestStringBytes); outputStream.close(); //获得响应状态 int responseCode = httpConn.getResponseCode(); if(HttpURLConnection.HTTP_OK == responseCode){//连接成功 //当正确响应时处理数据 StringBuffer sb = new StringBuffer(); String readLine; BufferedReader responseReader; //处理响应流,必须与服务器响应流输出的编码一致 responseReader = new BufferedReader(new InputStreamReader(httpConn.getInputStream(), ENCODING_UTF_8)); while ((readLine = responseReader.readLine()) != null) { sb.append(readLine).append(""); } responseReader.close(); tv.setText(sb.toString()); } }catch(Exception ex){ ex.printStackTrace(); } } 另例: String url = http://10.168.7.72/Test/test.do; HttpPost request = new HttpPost(url); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValue("name","taohaibing")); params.add(new BasicNameValue("sex","male")); request.setEntity(new UrlEncodeFormEntity(params,HTTP.UTF_8)); HttpResponse response = new DefaultHttpClient().execute(request); if(response.getStatusLine().getStatusCode()==200) { String result = EntityUtils..toString(response.getEntity()); }