将名称值对附加到另一个名称值对
这是调用方法的代码 -
NameValuePair[] data = {
new NameValuePair("first_name", firstName),
new NameValuePair("last_name", lastName),
new NameValuePair("email", email),
new NameValuePair("company", organization),
new NameValuePair("phone", phone)
};
SalesForceFormSubmissionUtil.submitForm(data,CONTACT_FOR_TYPE);
在被调用的方法中 -
public static void submitForm(NameValuePair[] givendata, String contactType) {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(Constants.SALESFORCE_URL);
NameValuePair[] data = {
new NameValuePair("oid", Constants.SALESFORCE_OID),
new NameValuePair(Constants.SALESFORCE_CAMPAIGN_ID, contactType)
};
post.setRequestBody(data);
我想添加给定的数据和数据并将其作为 post 请求发送。你们能建议我如何附加两者吗?
here is the code of the calling method -
NameValuePair[] data = {
new NameValuePair("first_name", firstName),
new NameValuePair("last_name", lastName),
new NameValuePair("email", email),
new NameValuePair("company", organization),
new NameValuePair("phone", phone)
};
SalesForceFormSubmissionUtil.submitForm(data,CONTACT_FOR_TYPE);
In the called method -
public static void submitForm(NameValuePair[] givendata, String contactType) {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(Constants.SALESFORCE_URL);
NameValuePair[] data = {
new NameValuePair("oid", Constants.SALESFORCE_OID),
new NameValuePair(Constants.SALESFORCE_CAMPAIGN_ID, contactType)
};
post.setRequestBody(data);
i want to add both the givendata & data and send it as a post request. Can you guys suggest me how to append both.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想合并两个数组,可以创建第三个数组 (
combinedData
),其大小为givenData.length
+data.length
,那么您必须从源数组中复制元素。不过,还有很多其他方法可以解决这个问题,例如:下面是使用 ArrayList 作为中间人/助手的实现。
输出
If you just want to combine the two arrays you can create a third array (
combinedData
) with a size ofgivenData.length
+data.length
, then you'll have to copy the elements from your source arrays.Though, there are plenty of other methods to solve this, as an example; below is an implementation using a
ArrayList
as a middle-man/helper.output