简体   繁体   English

如何在 HTTPURLConnection 中以 application/x-www-form-urlencoded 格式向 POST 调用添加正文

[英]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.

相关问题 FeignClient 使用 application/x-www-form-urlencoded 正文创建 POST - FeignClient create POST with application/x-www-form-urlencoded body 如何使用 webclient 发布正文 x-www-form-urlencoded? - how to post body x-www-form-urlencoded using webclient? 如何使用 x-www-form-urlencoded 正文发送 post 请求 - How to send post request with x-www-form-urlencoded body 如何以 application/x-www-form-urlencoded 在 restTemplate 中发送正文 - How to send body in restTemplate as application/x-www-form-urlencoded 未找到Form&application / x-www-form-urlencoded的Body Writer - Body Writer not found for Form & application/x-www-form-urlencoded 在正文中使用 application/x-www-form-urlencoded 的 400 错误白色 Java Post - 400 error white Java Post using application/x-www-form-urlencoded in body POST 调用接受 x-www-form-urlencoded 但拒绝 JSON - POST call accepts x-www-form-urlencoded but refuses JSON 如何使用Android批注和RestTemplate在POST请求的正文中发送x-www-form-urlencoded - How to send x-www-form-urlencoded in a body of POST request using android annotations and resttemplate POST x-www-form-urlencoded - POST x-www-form-urlencoded 如何使用关联数组解析 application/x-www-form-urlencoded? - How to parse a application/x-www-form-urlencoded with an associative array?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM