一、:1、先開啟你的netbeans IDE,選擇建立java web的wed application(next)
2、寫入你的工程名字並選擇路徑(next)
3、java ee版本選擇java ee5(finish)
4、以上完成後就單擊右鍵(projectname)建立基於模式REST風格的web........,選擇簡單,單擊next把MIME中
改為text/plain.(finish)
二、下載一個(blazeds.rar)解壓:
地址:百度一下就OK
把解壓後的檔案複製到你netbeans工程中的WEB_INF中。修改lib中的remoting-config.xml為:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<destination id="helloWorld">
<properties>
<source>com.ws.HelloWorlds</source>
</properties>
</service>
三、再在NetBeans工程中建一個類:HelloWorlds代碼如下:
public HelloWorlds(){
}
public String getHelloWorld(String name){
return "Hello "+name;
}
public String validatePassword(String name,String password){
return null;
}
四、接下來就開啟FlexBudler:
建立工程代碼如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:RemoteObject id="say" destination="helloWorld">
</mx:RemoteObject>
<mx:Button x="10" y="48" label="click" click="remotingSayHello(event)"/>
<mx:TextInput x="60" y="89" id="tiName"/>
<mx:Label x="10" y="91" text="name:"/>
<mx:Label x="259" y="91" text="{say.getHelloWorld.lastResult}" id="lblView" color="#FCEE09"/>
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public function remotingSayHello(event:Event):void{
var iname:String=tiName.text;
say.getHelloWorld(iname);
}
]]>
</mx:Script>
</mx:Application>
五、儲存並運行,點擊click。。。就OK啦。。
註:可能還不夠詳細,但是是可以看到簡單效果的。