转自http://www.cnblogs.com/noam/archive/2010/07/30/1788988.html
普通Java Web工程流行使用ssh框架,而当前台使用Flex制作的时候,后台就不需要用Struts了,通过使用BlazeDS远程方法调用即可。
首先,新建Java Web工程,然后添加Flex项目,详情见通过J2EE Web工程添加Flex项目,进行BlazeDS开发 。
随后,导入Jar包,flex相关的jar包在添加Flex项目的时候已经导入,这里主要是导入Spring和Hibernate相关 的jar包以及spring和flex集成的jar包,我用的是spring 3.0.3和hibernate 3.2.1。 下面是lib列表:
antlr-2.7.6.jar
asm-2.2.3.jarasm-commons-2.2.3.jarasm-util-2.2.3.jaraspectjlib.jaraspectjrt.jaraspectjweaver.jarbackport-util-concurrent.jarc3p0-0.9.1.jarcfgatewayadapter.jarcglib-nodep-2.1_3.jarcom.springsource.edu.emory.mathcs.backport-3.0.0.jarcom.springsource.net.sf.cglib-2.2.0.jarcom.springsource.org.aopalliance-1.0.0.jarcommons-codec-1.3.jarcommons-collections-3.1.jarcommons-httpclient-3.0.1.jarcommons-io-1.4.jarcommons-lang-2.3.jarcommons-logging.jardom4j-1.6.1.jarehcache-1.2.3.jarflex-messaging-common.jarflex-messaging-core.jarflex-messaging-opt.jarflex-messaging-proxy.jarflex-messaging-remoting.jarflex-rds-server.jarfreemarker-2.3.15.jarhibernate-commons-annotations-3.2.0.Final.jarhibernate-core-3.5.4-Final.jarhibernate-jpa-2.0-api-1.0.0.Final.jarjackson-lgpl-0.9.5.jarjavassist.jarjta-1.1.jarlog4j-1.2.15.jarmysql-connector-java-5.1.13-bin.jarorg.springframework.aop-3.0.3.RELEASE.jarorg.springframework.asm-3.0.3.RELEASE.jarorg.springframework.aspects-3.0.3.RELEASE.jarorg.springframework.beans-3.0.3.RELEASE.jarorg.springframework.context-3.0.3.RELEASE.jarorg.springframework.context.support-3.0.3.RELEASE.jarorg.springframework.core-3.0.3.RELEASE.jarorg.springframework.expression-3.0.3.RELEASE.jarorg.springframework.flex-1.0.3.RELEASE.jarorg.springframework.instrument-3.0.3.RELEASE.jarorg.springframework.instrument.tomcat-3.0.3.RELEASE.jarorg.springframework.jdbc-3.0.3.RELEASE.jarorg.springframework.jms-3.0.3.RELEASE.jarorg.springframework.orm-3.0.3.RELEASE.jarorg.springframework.oxm-3.0.3.RELEASE.jarorg.springframework.test-3.0.3.RELEASE.jarorg.springframework.transaction-3.0.3.RELEASE.jarorg.springframework.web-3.0.3.RELEASE.jarorg.springframework.web.portlet-3.0.3.RELEASE.jarorg.springframework.web.servlet-3.0.3.RELEASE.jarorg.springframework.web.struts-3.0.3.RELEASE.jarslf4j-api-1.5.8.jarslf4j-log4j12-1.5.8.jarxalan.jar
修改配置文件,web.xml,其中最重要的是修改原先MessegeBroker Servlet,改为由Spring web应用前端控制器处理所有请求。
配置 flex-application-config.xml,注意增加的几个命名空间,需要包 org.springframework.flex-1.0.3.RELEASE.jar ,同时在这个文件里定义了bean,在mxml里面会引用到:
hibernate的配置,用到c0p0.jar,
test.mxml,这里主要是定义和调用远程对象,远程对象的bean在上面的flex-application-config.xml里面有定义,调用类sample.Test.java中的createUser方法。