gpt4 book ai didi

Java url.openConnection()

转载 作者:行者123 更新时间:2023-12-02 07:57:13 29 4
gpt4 key购买 nike

1) 如何在 url.openConnection() 时发送特定的请求 header ?

2)另外,我怎样才能将请求转换为 POST 并发送 post 数据?

3) 您会推荐什么文档来进一步了解 url.openConnection() 及其可能性?

谢谢。

最佳答案

  1. connection.addRequestProperty(headerName, headerValue);

  2. 您应该调用 connection.setRequestMethod("POST");,然后调用 connection.getOutputStream() 并写入 的流内容POST 请求。

  3. google:“java http post 示例”带来了大量文档。这是第一个:http://www.exampledepot.com/egs/java.net/post.html

关于Java url.openConnection(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9453609/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com