gpt4 book ai didi

http post 请求不在 Blackberry 5.0 中发送参数

转载 作者:可可西里 更新时间:2023-11-01 16:52:41 27 4
gpt4 key购买 nike

我一直在处理 BlackBerry post 请求,请求正在发送,但参数似乎没有。这是我的代码:

        HttpConnection httpConnection = (HttpConnection) Connector.open(url);
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false);
encPostData.append("time", "1314144000");

System.out.println("url: " + httpConnection.getURL());

byte[] postData = encPostData.toString().getBytes("UTF-8");

System.out.println("post data: " + encPostData.toString());
httpConnection.setRequestProperty("Content-length", String.valueOf(postData.length));

System.out.println("url: " + httpConnection.getURL());
System.out.println("message:" + httpConnection.getResponseMessage());

OutputStream os = httpConnection.openOutputStream();
os.write(postData);
os.flush();
os.close();

我从服务器(我们设置的)得到的响应是我们没有发送时间戳。我的有什么问题吗

encPostData.append("time", "1314144000");

代码?

最佳答案

您在写入发布数据之前调用 getResponseMessage() 会在连接上写入任何内容之前强制响应。

System.out.println("message:" + httpConnection.getResponseMessage());

将它移到最后,在写入输出流数据之后,我认为它会更适合您。

关于http post 请求不在 Blackberry 5.0 中发送参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7516789/

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