Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java @已在HTTPPost请求中转换为%40_Java_Android_Http_Https_Http Headers - Fatal编程技术网

Java @已在HTTPPost请求中转换为%40

Java @已在HTTPPost请求中转换为%40,java,android,http,https,http-headers,Java,Android,Http,Https,Http Headers,我正在尝试向webservice发送post请求。。 当我在参数中添加特殊字符@时,它被转换为%40。我已经检查了服务器端。他们得到的是%40而不是@。 有人能帮我吗?? 这是我的密码 httpclient = new DefaultHttpClient(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValueP

我正在尝试向webservice发送post请求。。 当我在参数中添加特殊字符@时,它被转换为%40。我已经检查了服务器端。他们得到的是%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);
但它提出了不受支持的编码算法


请帮我解决这个问题。

您使用的是
UrlEncodedFormEntity
,它将显示内容。使用此编码将
@
转换为
%40
是正常的。收件人应该能够自动解码,尽管您可能必须使用正确的内容类型才能进行解码,但可能
application/x-www-form-urlencoded

您需要使用服务器端之类的东西,以便将
%40
转换回
@
。这同样适用于其他特殊字符。

使用
url解码器。解码(url)
这将非常有用。

您可以使用

URLDecoder.decode("urlcontext", "UTF-8");

要删除你通过的url中的任何特殊字符,我参加这次聚会肯定要迟到了,但我遇到了类似的问题。如果要解码url字符串,需要使用decodeURIComponent(url)。其中url是您试图解码的字符串


学校在解释这一点上做得很好

服务器端正确解码url编码吗?我想这就是它应该如何工作的。。。接收端应将其解码为
@
符号。另一种解释是,您对它进行了两次编码,但您发布的代码无法做到这一点。我可以在不取消编码的情况下发送参数吗…??或者有其他方法发送post请求吗?@NiravBhandari:最终,这取决于服务器的预期。通常,基于HTML表单发布请求时使用
x-www-form-urlencoded
。您应该了解服务器的期望值。
URLDecoder.decode("urlcontext", "UTF-8");