//webwork的文档中自带
The xwork-optional package from dev.java.net contains a module xwork-spring that contains all the necessary code to use Spring in WebWork. It contains primarily a SpringObjectFactory to wire up the dependencies for an Action before passing it to WebWork. Each action should be configured within a Spring application context as a prototype (because WebWork assumes a new instance of a class for every action invocation). Specify something like this in applicationContext.xml:
<bean name="some-action" class="fully.qualified.class.name" singleton="false">
<property name="someProperty"><ref bean="someOtherBean"/></property>
</bean>
and in xwork.xml:
<action name="myAction" class="some-action">
<result name="success">view.jsp</result>
</action>
Notice that the WebWork Action's class name some-action is the bean name defined in the Spring application context.
Another advantage of the SpringObjectFactory approach is that it can also be used to load interceptors using the same sort of logic. If the interceptor is stateless, then it's possible to create the interceptor as a singelton instance, but otherwise it's best to create it as a Spring prototype.
In order to be used, the default ObjectFactory that WebWork uses should be replaced with an instance of the SpringObjectFactory. There are two different ways to accomplish this. The first method is to use the ContextListener in the xwork-optional package. This method assumes that the Spring application context has already been configured. Add the following to web.xml:
<!-- This needs to be after Spring ContextLoaderListener -->
<listener>
<listener-class>com.opensymphony.xwork.spring.SpringObjectFactoryListener</listener-class>
</listener>
Note: this is actually a XWork configuration but for simplicity, I just assume WebWork.
The second method is to call the initObjectFactory method on com.opensymphony.xwork.spring.SpringObjectFactory. The easiest way to do this is to have Spring's application configure and supply the aforementioned method as the "init-method". Add the following to your applicationContext.xml:
<bean id="spring-object-factory" class="com.opensymphony.xwork.spring.SpringObjectFactory" init-method="initObjectFactory"/>
Note: The second option should work when only using Xwork (as compared to XW and WW2).
分享到:
相关推荐
如何实现webwork+spring+hibernate框架结合
webwork+spring+ibatis很适合初学者的实例
Webwork+spring+hibernate集成实例
webwork与spring集成
webwork+spring+hibernate整合开发网络书城 第5讲
WebWork+Spring.+Hibernate整合开发
webwork2.1 spring jar包
WebWork.Spring.Hibernate整合开发网络书城
最近在做个项目,用的是webwork+spring+hibernate,在网上看了不少webwork+spring的配制方式,大多都是老的配制方式,比如2.1.7的,webwork2.2.4新加了很多功能,和spring的配制也简单了很多,我做了一个简单的登录...
webwork+spring整合例子 内带使用说明 以及webwork文档(中文) 下载
在网上看到好多搭建过程,我也看了好多。 这个是用图释的方式描述了如何利用WEBWORK/SPRING/HIBERNATE三者搭建一个框架。
webwork+spring+hibernate 开发资料,例子和配置方式,希望对您有帮助!
webwork+Spring+ibatis 此为webwork+Spring+ibatis+freemarker 源码实例 因为包大,只好分开。。请一并下载webwork+Spring+ibatis_lib放入些实例中,,才能运行! 解压后,请参考mark.txt文件操作,即可!
struts2+webwork+spring.rarstruts2+webwork+spring.rar
webwork+spring+ibatis.rar
webwork+spring+hibernate入门实例,使用mysql数据库,建一个名为imti的数据库,把数据库文件导入数据库 把imti文件直接导入myeclipse
些为webwork+spring+hibernate+freemarker (A)demo_project下的lib 包,需要配合使用..
WebWork+Spring+Hibernate整合开发demo
WebWork.Spring.Hibernate整合开发网络书城全系列视屏,浪曦出品,共6讲,很适合初学者学习借鉴。这是第四讲。
webwork中结合spring说明,自己看吧,对你或许有用