@在HTTPPost请求中转换为%40

Nir*_*ari 9 java https android http http-headers

我试图发送邮件请求到webservice ..当我在参数中添加特殊字符@它被转换为%40.i已检查服务器端..他们正在获得%40而不是@.谁能帮我??这是我的代码..

httpclient = new DefaultHttpClient();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("Email", "abc@gmail.com"));


httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
 ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httppost,responseHandler);
Run Code Online (Sandbox Code Playgroud)

我也尝试过这种方法来防止我的参数编码.

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.PLAIN_TEXT_TYPE));
Run Code Online (Sandbox Code Playgroud)

但它提出了不受支持的编码算法

请帮我解决这个问题.

Bru*_*uno 7

您正在使用UrlEncodedFormEntity,它将内容进行URL编码.谈到@进入%40是正常的这种编码.收件人应该能够自动解码,尽管您可能必须使用正确的内容类型application/x-www-form-urlencoded.


Raj*_*esh 5

您可以使用

URLDecoder.decode("urlcontext", "UTF-8");
Run Code Online (Sandbox Code Playgroud)

从您传递的网址中删除任何特殊字符