BlazeDS HelloWorld项目配置过程

本文详细介绍使用MyEclipse 6.5、Tomcat 6.0和Flex 3.2搭建Flex应用的过程。从创建HelloWorld项目开始,逐步介绍index.mxml文件的配置、Java后台类HelloWorld.java的实现,以及remoting-config.xml的修改等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前学了一些,今天边想边做,细节搞错了。整理一下,做个备忘。

(特别感谢大胡同志! 大胡是个好同志啊)

 

MyEclipse 6.5 + Tomcat 6.0 + Flex 3.2

 

Step 1 :

 

Step 2 :

 

Step 3 :

 

Step 4 :


 



 

 

Step 5 :

 


 

Step 6 :

 

 

这之后的HelloWorld项目创建步骤,网上有很多文章。我就借鉴一下:

 

index.mxml的代码为:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	
	<mx:TextInput id="txtName" x="109" y="102"/>
	<mx:Button click="sayHello()" label="Hello!" x="211" y="132"/>
	
	<mx:RemoteObject id="ro" destination="helloworld" result="resultHello(event)" fault="faultHello(event)"/>
	
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.controls.Alert;

	[Bindable]
	private var helloResult:String;
	
	private function sayHello():void{
		ro.sayHello(txtName.text);
	}
	
	private function resultHello(event:ResultEvent):void{
		helloResult = event.result.toString();
		Alert.show(helloResult);
	}
	
	private function faultHello(event:FaultEvent):void{
		helloResult = event.fault.message.toString();
		Alert.show(helloResult);
	}
		]]>
	</mx:Script>
	
</mx:Application>

 

在src目录下创建hello文件夹,创建HelloWorld.java类:

package hello;

public class HelloWorld {
	
	public String sayHello(String name){
		System.out.println("Hello, " + name);
		return "Hello, " + name ;
	}
}

 

修改WebRoot\WEB-INF\flex\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>hello.HelloWorld</source>
		</properties>
	</destination>

</service>

 

基本就完事了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值