我们可以将 Struts 2.0 与 Spring 3.0 集成吗?
我是 Struts 新手。我们可以将 Struts 2.0 与 Spring 3.0 + 集成吗?我听到人们说“不可能整合它”。这是真的吗?
如果是的话,网上有没有教程有例子?
编辑:
有一个插件可以集成Struts 2和Spring 2 (struts2-spring-plugin-2.0.11.2.jar)。我们有类似的 Struts 2 和 Spring 3 吗
I am new to Struts . Can we integrate Struts 2.0 with Spring 3.0 + . I am hearing people say "it is not possible to integrate it". Is this true .
If so is there any tutorial on the web having an example ?
edit :
There is a plugin to integrate Struts 2 and Spring 2 (struts2-spring-plugin-2.0.11.2.jar) . Do we have similar one for Struts 2 and Spring 3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们总是可以将 Spring 3.x 与 Struts 2.x 一起使用,而 Struts2.x 已经有一个插件来实现这一点。
这是链接 Struts2 spring 集成
Struts2 使用其内部 DI使用插件创建 Actions、Results、Interceptor 会将创建这些关键对象的调用委托给 Spring DI。
希望这会帮助您
编辑
Strus2 Spring 插件即使在 Spring 3.x 上也能正常工作,我们在当前的应用程序中使用它,它实际上使用您的 Spring jar,您必须将它们放在 lib 中这个插件只是覆盖了Struts2.x对象工厂,它负责创建struts2核心组件。
因此,请继续进行一些实验,如果您在集成时遇到问题,您可以随时在此处发布查询
Well we always can use Spring 3.x with Struts 2.x and Struts2.x has already a plug in in place to accomplish this.
here is the link Struts2 spring Integration
Struts2 use its internal DI for creation of Actions,Results,Interceptor using the plug in will delegate the call of creation of these key objects to Spring DI.
hope this will help you
edit
The Strus2 Spring Plug in works well even with Spring 3.x and we are using this in our current application it actually use your Spring jars and you have to place them in the lib.This plug in just overrides Struts2.x Object factory which is responsible for creating struts2 core component.
So just go ahead do some experiment with it and if you face problem in integrating you can always post queries here
Struts 1.x 和 2.x 的 Spring 3.0 文档为 此处。
从技术上讲,将 Spring 与几乎任何东西集成都是可能的。例如,您可以通过构造新的 ClassPathXmlApplicationContext 并在类路径上传递标准上下文 XML 资源,从代码中的任何位置使用 IoC 容器。不过通常不需要这样做,因为它与大多数 Web 框架集成得很好。然而,它用于单元测试很方便。
The Spring 3.0 documentation for Struts 1.x and 2.x is here.
It's technically possible to integrate Spring with really just about anything. For example you can use the IoC container from anywhere in your code by constructing a new
ClassPathXmlApplicationContext
and passing in a standard context XML resource on the classpath. There's generally not a need to do that though, as it integrates pretty well with most web frameworks. It is however convenient to use for unit tests.