flex与java交互问题;高手指点指点..............
java端:servlet的doGet方法如下publicvoiddoGet(HttpServletRequestrequest,HttpServletResponser...
java端:
servlet的doGet方法如下
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
User user=(User)request.getAttribute("bean");
String id=request.getParameter("id");
String name=request.getParameter("name");
System.out.print(id+" "+name);
// System.out.print(user.getId()+user.getName());
}
flex端:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
</s:layout>
<fx:Script>
<![CDATA[
import client.MyUser;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
public var us:MyUser=new MyUser();
protected function service_faultHandler(event:FaultEvent):void
{
// TODO Auto-generated method stub
Alert.show("wrong");
}
protected function service_resultHandler(event:ResultEvent):void
{
// TODO Auto-generated method stub
Alert.show("ok");
}
protected function button1_clickHandler(event:MouseEvent):void
{
us.setId("myid");
us.setName("joy");
Alert.show(us.getId()+us.getName());
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:HTTPService id="service" fault="service_faultHandler(event)" url="http://localhost:8080/Bean/BeanServlet" result="service_resultHandler(event)">
<s:request>
<id>{myId.text}</id>
<name>{myname.text}</name>
<bean>{us}</bean>
</s:request>
</s:HTTPService>
</fx:Declarations>
<s:HGroup x="279" y="203" width="400" height="300">
<s:TextInput id="myId"/>
<s:TextInput id="myname"/>
<s:Button label="servlet" click="service.send()"/>
<s:Button label="fuzhi" click="button1_clickHandler(event)"/>
</s:HGroup>
</s:Application>
为什么在servlet中的user对象是空的,我测试过flex的us对象是有值的(通过单击按钮进行赋值),为什么取出后赋给java端的user对象后却没有值了,是不是不能这样赋值?还是其他原因............??????高手指点啊,急死了............ 展开
servlet的doGet方法如下
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
User user=(User)request.getAttribute("bean");
String id=request.getParameter("id");
String name=request.getParameter("name");
System.out.print(id+" "+name);
// System.out.print(user.getId()+user.getName());
}
flex端:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
</s:layout>
<fx:Script>
<![CDATA[
import client.MyUser;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
public var us:MyUser=new MyUser();
protected function service_faultHandler(event:FaultEvent):void
{
// TODO Auto-generated method stub
Alert.show("wrong");
}
protected function service_resultHandler(event:ResultEvent):void
{
// TODO Auto-generated method stub
Alert.show("ok");
}
protected function button1_clickHandler(event:MouseEvent):void
{
us.setId("myid");
us.setName("joy");
Alert.show(us.getId()+us.getName());
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:HTTPService id="service" fault="service_faultHandler(event)" url="http://localhost:8080/Bean/BeanServlet" result="service_resultHandler(event)">
<s:request>
<id>{myId.text}</id>
<name>{myname.text}</name>
<bean>{us}</bean>
</s:request>
</s:HTTPService>
</fx:Declarations>
<s:HGroup x="279" y="203" width="400" height="300">
<s:TextInput id="myId"/>
<s:TextInput id="myname"/>
<s:Button label="servlet" click="service.send()"/>
<s:Button label="fuzhi" click="button1_clickHandler(event)"/>
</s:HGroup>
</s:Application>
为什么在servlet中的user对象是空的,我测试过flex的us对象是有值的(通过单击按钮进行赋值),为什么取出后赋给java端的user对象后却没有值了,是不是不能这样赋值?还是其他原因............??????高手指点啊,急死了............ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询