1、web.xml中配置lcds
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>flcds</display-name>
<description>my flcds</description>
<!-- Http Flex Session attribute and binding listener support -->
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<!-- MessageBroker Servlet -->
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>
2、/WEB-INF/flex/services-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<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>
<!--my business class-->
<destination id="DataSource">
<properties>
<source>com.dream.main.DataSource</source>
<scope>application</scope>
</properties>
</destination>
</service>
</services>
<channels>
<!-- Servlet Based endpoints -->
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Debug">
<properties>
<prefix>[LCDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>*</pattern>
</filters>
</target>
</logging>
<system>
<redeploy>
<enabled>true</enabled>
<watch-interval>20</watch-interval>
<watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file>
<touch-file>{context.root}/WEB-INF/web.xml</touch-file>
</redeploy>
</system>
</services-config>
3、login.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
private function startLogin(str:String):void{
dataSource.login(str);
dataSource.addEventListener(ResultEvent.RESULT,handlerLogin);
}
private function handlerLogin(e:ResultEvent) :void {
Alert.show(e.result.toString(),"提示");
}
]]>
</mx:Script>
<mx:RemoteObject id="dataSource" destination="DataSource"/>
<mx:Button click="startLogin('忧里修斯')" label="登陆" x="252.5" y="190" width="132" height="32"/>
</mx:Application>
3、Java类,DataSource.java
package com.dream.main;
public class DataSource {
public String login(String username){
return username+":恭喜你,登陆成功!";
}
}
分享到:
相关推荐
Flex + LCDS + Java 入门教程Flex + LCDS + Java 入门教程Flex + LCDS + Java 入门教程
Flex + LCDS + Java Flex + LCDS + Java
Flex + LCDS + Java 入门教程 很多人在帖子和群中问到过一些关于建立Flex+LCDS(FDS)工程的问题,由于操作上的东西,很难简单说清楚,于是写了一个简单的教程(本来很早就答应过的,结果被newfish逮住做东西,加上...
Flex + LCDS + Java 入门与配置
Flex+LCDS+Java入门教程,如何使用MyEclips进行配置
转:Flex+++LCDS+++Java+入门教程
Flex_AS3\Flex + LCDS + Java 入门教程
一个用户管理实例,基于Java+Hibernate+Flex+LCDS,包括用户添加\\编辑\\修改和查询!(说明:由于文件过大,包删除了WEB-INF下的lib文件夹,里面的内容请到LCDS下的flex.war中拷贝即可)
Flex + LCDS + Java 入门教程 本教程通过图文介绍和对一些关键性的地方进行解释,让大家了解如何新建Flex的LCDS工程,并利用工具快速整合和部署J2EE项目和LCDS项目,掌握了简单的请求RemoteObject和配置的方法,...
Flex LCDS JAVA 入门学习教程