UrlEncodedFormEntity(nameValuePairs)将垃圾添加到参数值

时间:2015-06-12 07:22:04

标签: java apache-commons-httpclient

这是我的代码段:

HttpClient client = new DefaultHttpClient();    
String urlStr = FolderManager.ApplicationUnderTestUrl();
HttpPost post = new HttpPost(urlStr);   
List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>(1);

if ((paramName != null ) && (paramVal != null))
{
    for (int i = 0; i < paramName.length; i++) 
    {
        nameValuePairs.add(new BasicNameValuePair(paramName[i], paramVal[i]));
    }
}
post.setEntity(new UrlEncodedFormEntity(nameValuePairs ,"UTF-8"));      
HttpResponse response = client.execute(post);       
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));   

上面的代码在我的参数值中添加了一些+(加号)符号,无论在哪里&#39;遇到了#(空格)。我怎么能避免这个?

0 个答案:

没有答案