flex前端给服务器端传递参数可以有2种方式:
方式一:使用URL参数传递方式,使用navigationURL方法
var url:String = "http://www.baidu.com?name=zhangsan&password=111111";
navigateToURL(new URLRequest(url),"_blank");
方式二:使用HttpService组件
创建一HttpService组件对象:
<mx:HTTPService id="httpService"
showBusyCursor="true"
useProxy="false"
method="POST"
result="resultHander(event)"
fault="faultHander(event)"
resultFormat="text"/>
在方法中使用该HttpService组件对象发送:
private function linkAction():void {
var url:String = "http://www.baidu.com";
var params:URLVariables = new URLVariables();
params.name = encodeURIComponent("zhangsan");
params.lisi = encodeURIComponent("lisi");
httpService.url = url;
httpService.send(params);
}
而且在使用HttpService组件传递参数时,还可以指定方法类型是POST或GET方式。
二者在使用上的区别是:方式一将发生页面跳转,方式二仅仅是传递参数给服务器端,不会发生页面跳转。