如何在 Adob​​e Flex 3 中通过 HTTPservice 发送数组

发布于 2024-07-07 10:45:07 字数 45 浏览 7 评论 0原文

如何在 Adob​​e Flex3 中的 Httpservice 中发送数组

How to send array in Httpservice in Adobe Flex3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

樱娆 2024-07-14 10:45:15

如果它是一个简单的数组,您可以将其作为逗号分隔的字符串发送。

httpService.request = 新对象;
httpService.request.csv = array.toString();

If it is a simple array, you could send it as a comma separated string.

httpService.request = new Object;
httpService.request.csv = array.toString();

属性 2024-07-14 10:45:14

如果是简单的字符串数组,可以加入 它使用众所周知的分隔符字符,并在另一个站点上,将具有相同分隔符的字符串拆分回数组。

if it is a simple string array, you can join it with a well know separator char, and on the other site, split the string with the same separator back to an array.

情释 2024-07-14 10:45:13

这实际上取决于您使用的后端技术是什么。 如果您将其发送到 PHP,您可以尝试:

var fields:Array = ["categories", "organisation"];
var params:Object = {};
params.q = "stackoverflow";
params.rows = 0;
params.facet = "true";
params["facet.field[]"] = fields;
service.send(params);

PHP 将为您生成一个数组。
AFAIR 这在 Rails 中也能正常工作。

It really depends what is the back end technology you're using. If you're sending it to PHP you could try:

var fields:Array = ["categories", "organisation"];
var params:Object = {};
params.q = "stackoverflow";
params.rows = 0;
params.facet = "true";
params["facet.field[]"] = fields;
service.send(params);

PHP will generate an array for you.
AFAIR this works fine in Rails as well.

╰つ倒转 2024-07-14 10:45:12

我不太确定将数组发送到 httpservice 是什么意思。 如果您打算将数组发送到具有相同字段名称的 httpservice,则可以将数组作为字段值传递。

var service:HTTPService = new HTTPService();
service.useProxy = true;
service.destination = "myservicet";
service.resultFormat = HTTPService.RESULT_FORMAT_XML;

var fields:Array = ["categories", "organisation"];
var params:Object = new Object();
params.q = "stackoverflow";
params.rows = 0;
params.facet = "true";
params["facet.field"] = fields;
service.send(params);

HTTPService 会将其转换为 url 参数:

facet=true&q=stackoverflow&facet%2Efield=categories&facet%2Efield=organisation&rows=0

希望这有帮助!

添加是为了更加清晰。 当数组中只有 1 个参数时,不要将字段作为数组传递。 由于某种原因,flex 不会将其发送到 http 服务

I am not quite sure what you mean by sending an array to a httpservice. If you mean to send an array to a httpservice with the same field name, you can pass an array as field value.

var service:HTTPService = new HTTPService();
service.useProxy = true;
service.destination = "myservicet";
service.resultFormat = HTTPService.RESULT_FORMAT_XML;

var fields:Array = ["categories", "organisation"];
var params:Object = new Object();
params.q = "stackoverflow";
params.rows = 0;
params.facet = "true";
params["facet.field"] = fields;
service.send(params);

The HTTPService will convert this to the url parameters:

facet=true&q=stackoverflow&facet%2Efield=categories&facet%2Efield=organisation&rows=0

Hope this helps!

Added for more clarity. When there is only 1 argument in the array, do not pass the fields as an array. For some reason, flex will not send this to the http service

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文