浏览 11787 次
锁定老帖子 主题:webwork+spring最简单的集成
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2004-12-31
配置步骤: 1、在Web.xml文件中配置Spring Application Context: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 2、在xwork.xml文件中定义ActionAutowiringInterceptor,并配置到相应的Action中: <interceptor name="autowire" class="com.opensymphony.xwork.spring.interceptor.ActionAutowiringInterceptor"> <param name="autowireStrategy"> @org.springframework.beans.factory.config.AutowireCapableBeanFactory@AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE </param> </interceptor> 可以自己设置Bean组装的策略,上面的定义是根据类型组装。如果不设置,默认情况是根据Bean的名称组装。 详细参考:http://wiki.opensymphony.com/display/WW/WebWork+2+Spring+Integration ActionAutowiringInterceptor主要代码如下: protected void before(ActionInvocation invocation); throws Exception { if (!initialized); { ApplicationContext applicationContext = (ApplicationContext);ActionContext.getContext();.getApplication();.get( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);; if (applicationContext == null); { log.warn("ApplicationContext could not be found. Action classes will not be autowired.");; } else { setApplicationContext(applicationContext);; factory = new SpringObjectFactory();; factory.setApplicationContext(getApplicationContext(););; if (autowireStrategy != null); { factory.setAutowireStrategy(autowireStrategy.intValue(););; } } initialized = true; } if (factory == null); return; Action bean = invocation.getAction();; factory.autoWireBean(bean);; ActionContext.getContext();.put(APPLICATION_CONTEXT, context);; } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2004-12-31
我很笨,想起以前的笨拙的external
埃! 这个是最好的,都怪当初只认为外国人wiki上提供的方法是最好的 ,自己懒得动脑子,真是只会抄袭的家伙哦! |
|
返回顶楼 | |
发表时间:2005-01-07
小声的说:
谁能共享一个com.opensymphony.xwork.spring.interceptor.ActionAutowiringInterceptor这个么?我在公司不能上java.net |
|
返回顶楼 | |
发表时间:2005-01-07
http://forum.iteye.com/viewtopic.php?p=54959#54959
有个包下载 |
|
返回顶楼 | |
发表时间:2005-01-07
已经下载了,嗯,好用,谢谢
|
|
返回顶楼 | |