FlexWithJava.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:RemoteObject id="ud" destination="UserDao" result="onResult(event)" fault="onFault()" />
<mx:DataGrid dataProvider="{users}">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="name" />
</mx:columns>
</mx:DataGrid>
<mx:Label id="info" />
<mx:Button label="click" click="clickFun()" />
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
public var users:ArrayCollection=new ArrayCollection();
public function clickFun():void{
ud.getAllUser();
}
public function onResult(event:ResultEvent):void{
users=ArrayCollection(event.result);
info.text="get data successfully";
}
public function onFault():void{
info.text="Error";
}
]]>
</mx:Script>
</mx:Application>
第四,配置remoting-config.xml,在里面加上如下配置文件: