当前位置:编程学习 > JAVA >>

flex与servlet 交互

关于 flex 与 servlet 之间的交换方式总结一下

1 HTTPService
对于 flex 4 而言可以在<fx:Declarations> 标签中添加

Java代码 
<fx:Declarations> 
<mx:HTTPService id="httpservice" />//添加项 
</fx:Declarations> 
 
 
         protected function test():void 
         { 
                //在mxml中获取服务器的各种参数 
                var tempStr:String =Application.application.url; 
                var serverName:String =URLUtil.getServerName(tempStr); 
                var serverPort:String=URLUtil.getPort(tempStr).toString(); 
                var serverProtocol:String=URLUtil.getProtocol(tempStr); 
 
                //构建setvlet 请求路径 
                var uString:String = serverProtocol + "://" + serverName + ":" +serverPort+"/"+"mobile-store-system/";   //mobile-store-system 工程名 
                 
                //servlet路径  PrintWord 
                var url : String =uString+"PrintWord?type="+type+"&id="+id+"&pfileName="+docname; 
                 
 
                httpservice.url=uString; 
                httpservice.send() 
            } 


2    flash.net.navigateToURL;
  可以用来打开新窗口,当然包括与servlet交互
Java代码 
var url : String =uString+"PrintWord?type="+type+"&id="+id+"&    pfileName="+docname; 
var urlRequest:URLRequest = new URLRequest(url); 
navigateToURL(urlRequest, "_top"); 

        主要有两种方式  _top  本页打开
                                 _blank 新窗口

作者“lance9118”
 

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,