首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex中httpservice与java后盾交互的两种传值方式

2012-10-27 
flex中httpservice与java后台交互的两种传值方式环境:myeclipse8.5+flex4+blazeds????????????描述:flex4

flex中httpservice与java后台交互的两种传值方式

环境:myeclipse8.5+flex4+blazeds
????????????描述:flex4中httpservice与服务器端交互的值传递问题
????????????方式一:通过<s:request/>标签进行交互,在该标签内部以要传递的参数名作为该标签内的子标签,值作为内容进行传递,服务端接受数据采用request.getParmeter("参数名")获取数据.
????????????示例代码:
????????????flex中的代码:

flex中httpservice与java后盾交互的两种传值方式<!--定义HttpService发送请求-->
flex中httpservice与java后盾交互的两种传值方式????????<s:HTTPService?id="service"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????url="http://localhost:8080/testhttpservice/testHttpServiceServlet"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????useProxy="false"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????fault="service_faultHandler(event)"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????result="service_resultHandler(event)">
flex中httpservice与java后盾交互的两种传值方式????????????<!--第一种传值方式-->
flex中httpservice与java后盾交互的两种传值方式????????????
flex中httpservice与java后盾交互的两种传值方式????????????<s:request?>
flex中httpservice与java后盾交互的两种传值方式????????????????<!--参数名称作标签,中间填充参数值-->
flex中httpservice与java后盾交互的两种传值方式????????????????<username>{txtusername.text}</username>
flex中httpservice与java后盾交互的两种传值方式????????????????<password>{txtpassword.text}</password>
flex中httpservice与java后盾交互的两种传值方式????????????</s:request>
flex中httpservice与java后盾交互的两种传值方式????????????
flex中httpservice与java后盾交互的两种传值方式????????</s:HTTPService>

????????后台接受参数的代码:

flex中httpservice与java后盾交互的两种传值方式????????//获取flex传递的参数?username?password
flex中httpservice与java后盾交互的两种传值方式????????String?username=request.getParameter("username");
flex中httpservice与java后盾交互的两种传值方式????????//get方式处理乱码
flex中httpservice与java后盾交互的两种传值方式????????//username=new?String(username.getBytes("ISO-8859-1"),"utf-8");
flex中httpservice与java后盾交互的两种传值方式????????String?password=request.getParameter("password");
flex中httpservice与java后盾交互的两种传值方式????????//password=new?String(password.getBytes("ISO-8859-1"),"utf-8");

????????方式二:第二种传值方式通过send()方法传值send方法中传递参数 ,服务端接受数据采用request.getParmeter("参数名")获取数据.
????????示例代码:

flex中httpservice与java后盾交互的两种传值方式????????????????//第二种传值方式?通过send()方法传值?send方法中传递参数?
flex中httpservice与java后盾交互的两种传值方式????????????????//定义一object对象
flex中httpservice与java后盾交互的两种传值方式????????????????var?val:Object=new?Object();
flex中httpservice与java后盾交互的两种传值方式????????????????//分别将文本框username,password的值传递到后台
flex中httpservice与java后盾交互的两种传值方式????????????????//object对象.参数名=值???传值操作
flex中httpservice与java后盾交互的两种传值方式????????????????val.username=txtusername.text;
flex中httpservice与java后盾交互的两种传值方式????????????????val.password=txtpassword.text;
flex中httpservice与java后盾交互的两种传值方式????????????????service.send(val);

????????贴出完整的代码:
????????服务器端:

flex中httpservice与java后盾交互的两种传值方式package?com.servlet;
flex中httpservice与java后盾交互的两种传值方式
flex中httpservice与java后盾交互的两种传值方式import?java.io.IOException;
flex中httpservice与java后盾交互的两种传值方式import?java.io.PrintWriter;
flex中httpservice与java后盾交互的两种传值方式import?java.util.ArrayList;
flex中httpservice与java后盾交互的两种传值方式import?java.util.List;
flex中httpservice与java后盾交互的两种传值方式
flex中httpservice与java后盾交互的两种传值方式import?javax.servlet.ServletException;
flex中httpservice与java后盾交互的两种传值方式import?javax.servlet.http.HttpServlet;
flex中httpservice与java后盾交互的两种传值方式import?javax.servlet.http.HttpServletRequest;
flex中httpservice与java后盾交互的两种传值方式import?javax.servlet.http.HttpServletResponse;
flex中httpservice与java后盾交互的两种传值方式
flex中httpservice与java后盾交互的两种传值方式flex中httpservice与java后盾交互的两种传值方式/**?*//**
flex中httpservice与java后盾交互的两种传值方式?*?功能描述:flex?httpservice与java交互参数传递探讨<br>
flex中httpservice与java后盾交互的两种传值方式?*?@author?sxyx2008<br>
flex中httpservice与java后盾交互的两种传值方式?*?@date?2010-07-19
flex中httpservice与java后盾交互的两种传值方式?*
flex中httpservice与java后盾交互的两种传值方式?*/
flex中httpservice与java后盾交互的两种传值方式@SuppressWarnings("serial")
flex中httpservice与java后盾交互的两种传值方式flex中httpservice与java后盾交互的两种传值方式public?class?TestHttpServiceServlet?extends?HttpServlet?flex中httpservice与java后盾交互的两种传值方式{
flex中httpservice与java后盾交互的两种传值方式????
flex中httpservice与java后盾交互的两种传值方式????@Override
flex中httpservice与java后盾交互的两种传值方式????protected?void?service(HttpServletRequest?request,?HttpServletResponse?response)
flex中httpservice与java后盾交互的两种传值方式flex中httpservice与java后盾交互的两种传值方式????????????throws?ServletException,?IOException?flex中httpservice与java后盾交互的两种传值方式{
flex中httpservice与java后盾交互的两种传值方式????????//处理post方式乱码
flex中httpservice与java后盾交互的两种传值方式????????request.setCharacterEncoding("utf-8");
flex中httpservice与java后盾交互的两种传值方式????????//设置浏览器输出字符编码
flex中httpservice与java后盾交互的两种传值方式????????response.setCharacterEncoding("utf-8");
flex中httpservice与java后盾交互的两种传值方式????????PrintWriter?writer=response.getWriter();
flex中httpservice与java后盾交互的两种传值方式????????//获取flex传递的参数?username?password
flex中httpservice与java后盾交互的两种传值方式????????String?username=request.getParameter("username");
flex中httpservice与java后盾交互的两种传值方式????????//get方式处理乱码
flex中httpservice与java后盾交互的两种传值方式????????
flex中httpservice与java后盾交互的两种传值方式????????//username=new?String(username.getBytes("ISO-8859-1"),"utf-8");
flex中httpservice与java后盾交互的两种传值方式????????String?password=request.getParameter("password");
flex中httpservice与java后盾交互的两种传值方式????????//password=new?String(password.getBytes("ISO-8859-1"),"utf-8");
flex中httpservice与java后盾交互的两种传值方式????????
flex中httpservice与java后盾交互的两种传值方式????????//构建一个list存放一些数据用来模拟用户是否存在这一功能
flex中httpservice与java后盾交互的两种传值方式????????List<String>?list=new?ArrayList<String>();
flex中httpservice与java后盾交互的两种传值方式????????list.add("张三");
flex中httpservice与java后盾交互的两种传值方式????????list.add("李四");
flex中httpservice与java后盾交互的两种传值方式????????list.add("王五");
flex中httpservice与java后盾交互的两种传值方式????????list.add("曹操");
flex中httpservice与java后盾交互的两种传值方式????????list.add("孙权");
flex中httpservice与java后盾交互的两种传值方式????????list.add("刘备");
flex中httpservice与java后盾交互的两种传值方式????????//检验用户
flex中httpservice与java后盾交互的两种传值方式flex中httpservice与java后盾交互的两种传值方式????????if(list.contains(username))flex中httpservice与java后盾交互的两种传值方式{
flex中httpservice与java后盾交互的两种传值方式????????????writer.print("存在:"+username+"客户端传递的密码是:"+password);
flex中httpservice与java后盾交互的两种传值方式flex中httpservice与java后盾交互的两种传值方式????????}elseflex中httpservice与java后盾交互的两种传值方式{
flex中httpservice与java后盾交互的两种传值方式????????????writer.print("找不到:"+username+"客户端传递的密码是:"+password);
flex中httpservice与java后盾交互的两种传值方式????????}
flex中httpservice与java后盾交互的两种传值方式????????
flex中httpservice与java后盾交互的两种传值方式????}
flex中httpservice与java后盾交互的两种传值方式}
flex中httpservice与java后盾交互的两种传值方式

????????flex代码:

flex中httpservice与java后盾交互的两种传值方式<?xml?version="1.0"?encoding="utf-8"?>
flex中httpservice与java后盾交互的两种传值方式<s:Application?xmlns:fx="http://ns.adobe.com/mxml/2009"?
flex中httpservice与java后盾交互的两种传值方式???????????????xmlns:s="library://ns.adobe.com/flex/spark"?
flex中httpservice与java后盾交互的两种传值方式???????????????xmlns:mx="library://ns.adobe.com/flex/mx"?minWidth="955"?minHeight="600">
flex中httpservice与java后盾交互的两种传值方式????<fx:Script>
flex中httpservice与java后盾交互的两种传值方式????????<![CDATA[
flex中httpservice与java后盾交互的两种传值方式????????????import?mx.controls.Alert;
flex中httpservice与java后盾交互的两种传值方式????????????import?mx.rpc.events.FaultEvent;
flex中httpservice与java后盾交互的两种传值方式????????????import?mx.rpc.events.ResultEvent;
flex中httpservice与java后盾交互的两种传值方式
flex中httpservice与java后盾交互的两种传值方式????????????//调用失败
flex中httpservice与java后盾交互的两种传值方式????????????protected?function?service_faultHandler(event:FaultEvent):void
flex中httpservice与java后盾交互的两种传值方式????????????{
flex中httpservice与java后盾交互的两种传值方式????????????????Alert.show("失败了:"+event.message,"提示");
flex中httpservice与java后盾交互的两种传值方式????????????}
flex中httpservice与java后盾交互的两种传值方式
flex中httpservice与java后盾交互的两种传值方式????????????//调用成功
flex中httpservice与java后盾交互的两种传值方式????????????protected?function?service_resultHandler(event:ResultEvent):void
flex中httpservice与java后盾交互的两种传值方式????????????{
flex中httpservice与java后盾交互的两种传值方式????????????????Alert.show("成功了:"+event.result?as?String,"提示");
flex中httpservice与java后盾交互的两种传值方式????????????}
flex中httpservice与java后盾交互的两种传值方式????
flex中httpservice与java后盾交互的两种传值方式????????????//调用
flex中httpservice与java后盾交互的两种传值方式????????????protected?function?button1_clickHandler(event:MouseEvent):void
flex中httpservice与java后盾交互的两种传值方式????????????{
flex中httpservice与java后盾交互的两种传值方式????????????????//第一种传值方式????????????????
flex中httpservice与java后盾交互的两种传值方式????????????????//service.send();
flex中httpservice与java后盾交互的两种传值方式????????????????
flex中httpservice与java后盾交互的两种传值方式????????????????//第二种传值方式?通过send()方法传值?send方法中传递参数?
flex中httpservice与java后盾交互的两种传值方式????????????????//定义一object对象
flex中httpservice与java后盾交互的两种传值方式????????????????var?val:Object=new?Object();
flex中httpservice与java后盾交互的两种传值方式????????????????//分别将文本框username,password的值传递到后台
flex中httpservice与java后盾交互的两种传值方式????????????????//object对象.参数名=值???传值操作
flex中httpservice与java后盾交互的两种传值方式????????????????val.username=txtusername.text;
flex中httpservice与java后盾交互的两种传值方式????????????????val.password=txtpassword.text;
flex中httpservice与java后盾交互的两种传值方式????????????????service.send(val);
flex中httpservice与java后盾交互的两种传值方式????????????}
flex中httpservice与java后盾交互的两种传值方式
flex中httpservice与java后盾交互的两种传值方式????????]]>
flex中httpservice与java后盾交互的两种传值方式????</fx:Script>
flex中httpservice与java后盾交互的两种传值方式????<fx:Declarations>
flex中httpservice与java后盾交互的两种传值方式????????<!--?将非可视元素(例如服务、值对象)放在此处?-->
flex中httpservice与java后盾交互的两种传值方式????????<!--定义HttpService发送请求-->
flex中httpservice与java后盾交互的两种传值方式????????<s:HTTPService?id="service"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????url="http://localhost:8080/testhttpservice/testHttpServiceServlet"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????useProxy="false"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????fault="service_faultHandler(event)"?
flex中httpservice与java后盾交互的两种传值方式???????????????????????result="service_resultHandler(event)">
flex中httpservice与java后盾交互的两种传值方式????????????<!--第一种传值方式-->
flex中httpservice与java后盾交互的两种传值方式????????????
flex中httpservice与java后盾交互的两种传值方式????????????<s:request?>
flex中httpservice与java后盾交互的两种传值方式????????????????<!--参数名称作标签,中间填充参数值-->
flex中httpservice与java后盾交互的两种传值方式????????????????<username>{txtusername.text}</username>
flex中httpservice与java后盾交互的两种传值方式????????????????<password>{txtpassword.text}</password>
flex中httpservice与java后盾交互的两种传值方式????????????</s:request>
flex中httpservice与java后盾交互的两种传值方式????????????
flex中httpservice与java后盾交互的两种传值方式????????</s:HTTPService>
flex中httpservice与java后盾交互的两种传值方式????????
flex中httpservice与java后盾交互的两种传值方式????????
flex中httpservice与java后盾交互的两种传值方式????</fx:Declarations>
flex中httpservice与java后盾交互的两种传值方式????<s:TextInput?x="332"?y="196"?id="txtusername"/>
flex中httpservice与java后盾交互的两种传值方式????<s:TextInput?x="332"?y="256"?id="txtpassword"?displayAsPassword="true"/>
flex中httpservice与java后盾交互的两种传值方式????<s:Button?x="357"?y="311"?label="发送"?click="button1_clickHandler(event)"/>
flex中httpservice与java后盾交互的两种传值方式????<s:Label?x="290"?y="206"?text="用户名:"/>
flex中httpservice与java后盾交互的两种传值方式????<s:Label?x="297"?y="266"?text="密码:"/>
flex中httpservice与java后盾交互的两种传值方式</s:Application>
flex中httpservice与java后盾交互的两种传值方式

热点排行