搭建Flex41+Spring+HibernateWord下载.docx

上传人:b****5 文档编号:21144719 上传时间:2023-01-27 格式:DOCX 页数:35 大小:630.28KB
下载 相关 举报
搭建Flex41+Spring+HibernateWord下载.docx_第1页
第1页 / 共35页
搭建Flex41+Spring+HibernateWord下载.docx_第2页
第2页 / 共35页
搭建Flex41+Spring+HibernateWord下载.docx_第3页
第3页 / 共35页
搭建Flex41+Spring+HibernateWord下载.docx_第4页
第4页 / 共35页
搭建Flex41+Spring+HibernateWord下载.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

搭建Flex41+Spring+HibernateWord下载.docx

《搭建Flex41+Spring+HibernateWord下载.docx》由会员分享,可在线阅读,更多相关《搭建Flex41+Spring+HibernateWord下载.docx(35页珍藏版)》请在冰豆网上搜索。

搭建Flex41+Spring+HibernateWord下载.docx

--HttpFlexSessionattributeandbindinglistenersupport-->

listener>

listener-class>

flex.messaging.HttpFlexSession<

/listener-class>

/listener>

--MessageBrokerServlet-->

servlet>

servlet-name>

MessageBrokerServlet<

/servlet-name>

<

--<

display-name>

/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>

url-pattern>

/messagebroker/*<

/url-pattern>

/servlet-mapping>

8.将web工程添加到tomcat中

启动tomcat

9.添加Flex工程

右键HCS,选择:

添加/更改项目类型—>

添加Flex项目类型

注:

服务技术选择如下

10.点Next,如下配置

11.点击Finish,配置Flex项目属性

在Flex视图下,右键properties打开项目属性设置对话框

12.点击OK,这是工程中的没有http-template文件夹,然后在Flex视图下,右键properties打开项目属性设置对话框

将”生成HTML包装器文件”的钩钩去掉,点击Apply,在将此钩钩钩上点击OK,工程下面就会出现http-template文件夹

13,这是http-template文件夹下面的index.template.html文件报错,打开此文件,删除这行注释

--Forversiondetection,settomin.requiredFlashPlayerversion,or0(or0.0.0),fornoversiondetection.-->

保存就没错了

13.到了这个时候基本上已经搭建好Flex+bleazeds的web环境,现在来测试一下

1.)新建一个包:

com.zuohd.hcs.user.web

2.)在包中新一个类:

HelloWorld,作用flex的一个远程对象,HelloWorld中的代码如下

packagecom.zuohd.hcs.user.web;

publicclassHelloWorld{

publicStringsayHelloTo(Stringname){

return"

Hello"

+name;

}

}

3.)在HCS/WebRoot/WEB-INF/flex/remoting-config.xml注册这个远程对象

destinationid="

Hello"

>

<

properties>

<

source>

com.zuohd.hcs.user.web.HelloWorld<

/source>

/properties>

/destination>

4.)在src/HCS.mxml中添加以下代码:

?

xmlversion="

1.0"

encoding="

utf-8"

mx:

Applicationxmlns:

mx="

layout="

absolute"

Script>

[CDATA[

privatefunctionremotingSayHello(event:

Event):

void{

variname:

String=tiName.text;

say.sayHelloTo(iname);

}

]]>

/mx:

RemoteObjectid="

say"

destination="

RemoteObject>

Buttonx="

335"

y="

80"

label="

Click"

click="

remotingSayHello(event);

"

/>

TextInputx="

159"

id="

tiName"

Labelx="

109"

82"

text="

name:

Labeltext="

{say.sayHelloTo.lastResult}"

x="

44"

162"

width="

448"

height="

71"

lblView"

color="

#FCEE09"

fontSize="

20"

fontWeight="

bold"

textDecoration="

underline"

fontStyle="

normal"

Application>

5.)启动tomcat,等tomcat启动好后,右键单击HCS.mxml,选中RunAs—>

Web应用程序,效果如下

到了这一步,flex+bleazeds已经完成

14.添加Spring框架,在MyEclipseJavaEnterprise视图下的步骤如下:

点击HCS工程—>

MyEclipse—>

AddSpringCapabilities

点击Next

点击Finish

点击KeepExisting

15.添加mon,添加SpringFactory.java(网上的)

packagemon;

importorg.springframework.context.ApplicationContext;

importorg.springframework.web.context.support.WebApplicationContextUtils;

importorg.springframework.beans.BeansException;

importorg.springframework.beans.factory.NoSuchBeanDefinitionException;

importflex.messaging.FactoryInstance;

importflex.messaging.FlexFactory;

importflex.messaging.config.ConfigMap;

importflex.messaging.services.ServiceException;

/**

*Thisinterfaceisimplementedbyfactorycomponentswhichprovide

*instancestotheflexmessagingframework.Toconfigureflexdataservices

*tousethisfactory,addthefollowinglinestoyourservices-config.xml

*file(locatedintheWEB-INF/flexdirectoryofyourwebapplication).

*

*&

lt;

factories&

gt;

factoryid="

spring"

class="

flex.samples.factories.SpringFactory"

/&

/factories&

*Youalsomustconfigurethewebapplicationtousespringandmustcopythespring.jar

*fileintoyourWEB-INF/libdirectory.Toconfigureyourappservertousespring,

*youaddthefollowinglinestoyourWEB-INF/web.xmlfile:

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&

*

*ThenyouputyourspringbeanconfigurationinWEB-INF/applicationContext.xml(asperthe

*lineabove).Forexample:

UTF-8"

&

DOCTYPEbeansPUBLIC"

-//SPRING//DTDBEAN//EN"

http:

//www.springframework.org/dtd/spring-beans.dtd"

beans&

beanname="

weatherBean"

dev.weather.WeatherService"

singleton="

true"

/&

/beans&

*Nowyouarereadytodefineadestinationinflexthatmapstothisexistingservice.

*Todothisyou'

daddthistoyourWEB-INF/flex/remoting-config.xml:

WeatherService"

properties&

factory&

spring&

/factory&

source&

weatherBean&

/source&

/properties&

/destination&

*@authorJeffVroom

*/

publicclassSpringFactoryimplementsFlexFactory

{

privatestaticfinalStringSOURCE="

source"

;

/**

*Thismethodcanbeusedtoinitializethefactoryitself.Itiscalledwithconfiguration

*parametersfromthefactorytagwhichdefinestheidofthefactory.

publicvoidinitialize(Stringid,ConfigMapconfigMap){}

*Thismethodiscalledwhenweinitializethedefinitionofaninstance

*whichwillbelookedupbythisfactory.Itshouldvalidatethat

*thepropertiessuppliedarevalidtodefineaninstance.

*Anyvalidpropertiesusedforthisconfigurationmustbeaccessedto

*avoidwarningsaboutunusedconfigurationelements.Ifyourfactory

*isonlyusedforapplicationscopedcomponents,thismethodcansimply

*returnafactoryinstancewhichdelegatesthecreationofthecomponent

*totheFactoryInstance'

slookupmethod.

publicFactoryInstancecreateFactoryInstance(Stringid,ConfigMapproperties)

{

SpringFactoryInstanceinstance=newSpringFactoryInstance(this,id,properties);

instance.setSource(properties.getPropertyAsString(SOURCE,instance.getId()));

returninstance;

}//endmethodcreateFactoryInstance()

*Returnstheinstancespecifiedbythesource

*andpropertiesarguments.Forthefactory,thismaymean

*constructinganewinstance,optionallyregisteringitinsomeother

*namespacesuchasthesessionorJNDI,andthenreturningit

*oritmaymeancreatinganewinstanceandreturningit.

*Thismethodiscalledforeachrequesttooperateonthe

*givenitembythesystemsoitshouldberelativelyefficient.

*<

p>

*Ifyourfactorydoesnotsupportthescopeproperty,it

*reportanerrorifscopeissuppliedintheproperties

*forthisinstance.

publicObjectlookup(FactoryInstanceinst)

SpringFactoryInstancefactoryInstance=(SpringFactoryInstance)inst;

returnfactoryInstance.lookup();

}

 

staticclassSpringFactoryInstanceextendsFactoryInstance

SpringFactoryInstance(SpringFactoryfactory,Stringid,ConfigMapproperties)

super(factory,id,properties);

publicStringtoString()

return"

SpringFactoryinstanceforid="

+getId()+"

source="

+getSource()+"

scope="

+getScope();

publicObjectlookup()

ApplicationContextappContext=WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());

StringbeanName=getSource();

try

returnappContext.getBean(beanName);

catch(NoSuchBeanDefinitionExceptionnexc)

ServiceExceptione=newServiceException();

Stringmsg="

Springservicenamed'

+beanName+"

'

doesnotexist."

e.setMessage(msg);

e.setRootCause(nexc);

e.setDetails(msg);

e.setCode("

Server.Processing"

);

throwe;

catch(BeansExceptionbexc)

UnabletocreateSpringservicenamed'

e.setRootCause(bexc);

16.在WEB-INF/flex中的services-config.xml中注册SpringFactory工厂

factories>

mon.SpringFactory"

/factories>

17.在WEB-INF文件夹下建立conf文件夹,将applicationContext.xml移入此中,在WEB-INF/web.xml中加入对spring的支持

--Spring配置-->

--Backendconfiguration-->

context-param>

contextConfigLocation<

/WEB-INF/conf/*/spring-*.xml,

/WEB-INF/conf/applicationContext.xml

/context-param>

SpringContextServlet<

org.springframework.web.context.ContextLoaderServlet

Sprin

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1