首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

跟小弟我StepByStep学FLEX教程-Demo12之FLEX和Spring整合

2012-11-10 
跟我StepByStep学FLEX教程------Demo12之FLEX和Spring整合跟我StepByStep学FLEX教程------FLEX和Spring整

跟我StepByStep学FLEX教程------Demo12之FLEX和Spring整合

跟我StepByStep学FLEX教程------FLEX和Spring整合?

?

?

说明:该文系作者原创,请勿商用或者用于论文发表,转载必须经作者同意并且注明出处。

?

?

????? 这一讲是基于DEMO11,所以没有看DEMO11的读者请一定阅读,因为Spring的整合是基于J2EE的。

????? 因为要和Spring整合,所以先简单讲一下Spring(如果要对Spring没有接触过的读者也没关系,按照讲的内容也能做,但是这样没啥实际意义,所以要对本讲要有所收获,必须对Spring有一定的理解)。

????? 首先下载Spring,作者选择的Spring版本Spring Framework2.0.8。可以在官网


?

?*? </factories>
?*
?* You also must configure the web application to use spring and must copy the spring.jar
?* file into your WEB-INF/lib directory.? To configure your app server to use spring,
?* you add the following lines to your WEB-INF/web.xml file:
?*
?*?? <context-param>
?*??????? <param-name>contextConfigLocation</param-name>
?*??????? <param-value>/WEB-INF/applicationContext.xml</param-value>
?*?? </context-param>
?*
?*?? <listener>
?*?????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
?*?? </listener>
?*
?* Then you put your spring bean configuration in WEB-INF/applicationContext.xml (as per the
?* line above).? For example:
?*
?*? <?xml version="1.0" encoding="UTF-8"?>
?*? <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
?*??
?*? <beans>
?*??? <bean name="weatherBean" singleton="true"/>
?*? </beans>
?*?
?* Now you are ready to define a destination in flex that maps to this existing service.
?* To do this you'd add this to your WEB-INF/flex/remoting-config.xml:
?*
?*? <destination id="WeatherService">
?*????? <properties>
?*????????? <factory>spring</factory>
?*????????? <source>weatherBean</source>
?*????? </properties>
?*? </destination>
?*
?* @author Jeff Vroom
?*/
public class SpringFactory implements FlexFactory
{
??? private static final String SOURCE = "source";

??????? return instance;
??? } // end method createFactoryInstance()

??????????????? e.setMessage(msg);
??????????????? e.setRootCause(nexc);
??????????????? e.setDetails(msg);
??????????????? e.setCode("Server.Processing");
??????????????? throw e;
??????????? }
??????????? catch (BeansException bexc)
??????????? {
??????????????? ServiceException e = new ServiceException();
??????????????? String msg = "Unable to create Spring service named '" + beanName + "' ";
??????????????? e.setMessage(msg);
??????????????? e.setRootCause(bexc);
??????????????? e.setDetails(msg);
??????????????? e.setCode("Server.Processing");
??????????????? throw e;
??????????? }
??????? }
???????
??? }

13 楼 wx886104 2010-05-22   从你这学到新东西,我回继续学习 14 楼 lzg128 2010-09-30   楼主,你好!
   方便把案例代码发给我看下吗? 谢谢  790867479@qq.com 15 楼 hanyuxiao 2010-11-26   王大大,我咨询一个问题,如果spring使用注解的方式,这样也可以吗?有没有更好的解决方案?

热点排行