我需要使用特殊字符,stringentity
如下所示.
DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpEntity entity = new StringEntity("test®"); httpPost.setEntity(entity); httpPost.setHeader("Accept-Encoding", "UTF-8"); HttpResponse response = httpClient.execute(httpPost); BufferedReader reader = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); while ((reader.readLine()) != null) { System.out.println (reader.readLine()); } reader.close();
输出包含test�
而不是test®
在响应中.