[英]How to add a body to POST call in HTTPURLConnection in application/x-www-form-urlencoded format
How to add a body to POST call in HTTPURLConnection in application/x-www-form-urlencoded format (JAVA)如何以 application/x-www-form-urlencoded 格式 (JAVA) 向 HTTPURLConnection 中的 POST 调用添加正文
JDK version is 1.8 JDK 版本是 1.8
Code tried:代码尝试:
String parameters = "key=value";
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
wr.write(urlParameters);
The issue is fixed Used:问题已修复 使用:
String parameters = "key=value";
byte[] parameters = urlParameters.getBytes(Charset.forName("UTF-8"));
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
wr.write(urlParameters);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.