Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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 @电子邮件编码中的字符_Java_Http_Character Encoding_Apache Httpclient 4.x - Fatal编程技术网

Java @电子邮件编码中的字符

Java @电子邮件编码中的字符,java,http,character-encoding,apache-httpclient-4.x,Java,Http,Character Encoding,Apache Httpclient 4.x,我正在使用一个HttpPost(apachehttp客户端)实例发送电子邮件和密码,作为表单参数“application/x-www-form-urlencoded”。我的问题是,电子邮件值被编码为“someEmail%40gmail.com”,应该是“someEmail@gmail.com“ List nameValuePair=new ArrayList(); for(条目:params.entrySet()) 添加(新的BasicNameValuePair(entry.getKey(),e

我正在使用一个HttpPost(apachehttp客户端)实例发送电子邮件和密码,作为表单参数“application/x-www-form-urlencoded”。我的问题是,电子邮件值被编码为“someEmail%40gmail.com”,应该是“someEmail@gmail.com“

List nameValuePair=new ArrayList();
for(条目:params.entrySet())
添加(新的BasicNameValuePair(entry.getKey(),entry.getValue());
UrlEncodedFormEntity formEntity=新的UrlEncodedFormEntity(nameValuePair);
post.setEntity(formEntity);

我如何解决这个问题?

没关系。
@
字符在URL(
x-www-form-urlencoded
)中无效,必须正确编码

您的服务器在解码它时应该没有问题

  List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();

  for (Entry<String, String> entry: params.entrySet())
       nameValuePair.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));

  UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePair);
  post.setEntity(formEntity);