flex与java交互问题,将flex的类对象放入httpservice的request中,为什么在java端取出来是空对象??

大侠指点,为什么user对象是空的???Flex端:MyUser.as如下:packageclient{[RemoteClass(alias="mybean.User")... 大侠指点,为什么user对象是空的???
Flex端:
MyUser.as如下:
package client
{
[RemoteClass(alias="mybean.User")]
public class MyUser
{
private var Id:String;
private var Name:String;

public function MyUser()
{
}

public function getName():String
{
return this.Name;
}

public function setName(Name:String):void
{
this.Name = Name;
}

public function getId():String
{
return this.Id;
}

public function setId(Id:String):void
{
this.Id = Id;
}

}
Bean_Client.mxml如下:
<?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>
java端:
server的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());
}
User.java如下:
package mybean;

public class User {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
展开
 我来答
仇夜绿zc
2011-08-13 · 超过16用户采纳过TA的回答
知道答主
回答量:55
采纳率:0%
帮助的人:49.6万
展开全部
User 与 myUser 两个类的字段要相同啊
User 是id 而myUser 中又是ID 不能这样吧
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式