spring框架mvc能替代struts吗?或者我很困惑?
struts(1 或 2?)严格用于 MVC 类型架构还是还有更多内容?
我问的原因是我正在查看一个Web应用程序,他们似乎同时使用了spring和struts。
is struts (1 or 2?) used strictly for MVC type architecture or is there more to it?
reason I am asking is I am looking at a web application and they seem to be using both spring and struts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
总结一下:
To summarize:
嗯... Struts 2(又名 WebWork 2)是一个 MVC 框架,如 Spring MVC 或Stripes 框架。它们都是替代方案,并且针对表示层(并且仅针对表示层)。
使用 Struts 2(或 Stripes)并不排除使用 Spring 进行依赖注入(和其他服务)。换句话说,您不必在表示层级别使用 Spring MVC 才能在其他级别使用 Spring。实际上,大多数框架(至少对于 Struts 2 和 Stripes 框架来说是这样)确实提供了很好的 Spring 集成,由于 Spring 的流行,这在某种程度上是强制性的。
Hmm... Struts 2 (AKA WebWork 2) is a MVC framework like Spring MVC or Stripes Framework. They are all alternatives and target the presentation layer (and only the presentation layer).
Using Struts 2 (or Stripes) doesn't exclude using Spring for Dependency Injection (and other services). In other words, you don't have to use Spring MVC at the presentation layer level to use Spring at other levels. Actually, most frameworks (this is at least true for Struts 2 and the Stripes framework) do provide nice Spring integration which is somehow something mandatory because of Spring popularity.
Spring 是一头多头野兽,可用于各种应用程序、Web 等。当您将 Spring 用于 Web 应用程序时,您可以一直使用 Spring 自己的 MVC 框架来处理应用程序的特定于 Web 的部分。但你不必这样做。 Spring 的后端方面 - 即构成应用程序各个组件的所有 bean 以及与它们一起使用的各种 Spring 工具(事务管理、安全性等)可以与任何前端一起使用。显式插件可用于将 Spring 与 Struts、Struts 2 和其他一些集成,但即使这是可选的,您也可以在没有任何 MVC 框架的情况下使用 Spring。
Spring is a many-headed beast, and can be used for all kinds of applications, web and otherwise. When you use Spring for a web application, you can go all the way and use Spring's very own MVC framework for handling the web-specific portions of your application. But you don't have to. The back end aspects of Spring - that is, all the beans that make up the various components of your application and the various Spring tools you use with them (transaction management, security etc) can be used with any front end. Explicit plug-ins are available to integrate Spring with Struts, Struts 2, and some others, but even that is optional and you can use Spring without any MVC framework at all.
Spring 几乎从一开始就支持 Struts。 Struts 用作 MVC(后端的某种 DTO 传递机制),所有后端逻辑均由 Spring 处理,提供 IoC 并映射到 Struts。阅读更多信息< /a> 和此处
Spring was supporting Struts almost from the beginning. Struts is used as MVC (sorta DTO delivery mechanizm to the backend) and all the backend logic is handled by Spring providing IoC and mapping to the Struts. Read more here and here