为什么使用Spring而不是JSF(Spring相对于JSF的优点)?
我不太了解 JSF,我有一个朋友只使用 JSF 他问了我一个非常开放的问题,为什么你使用 spring 而不是 jsf ? 因为我的脑海里有很多关于春天的事情 我无法给出一些直接的答案 那么Spring相对于JSF有哪些优势呢?
i don't know JSF very well, and i have a friend who is using only JSF
and he asked me a very open question, why do you use spring not jsf ?
and because of there are a lot of things about spring in my mind
i wasn't able to give some straight answers
so what are the advantages of spring over JSF ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Spring 和 JSF 是完全不同的框架。
JSF 更多的是一个 Web 应用程序框架,您仍然可以将 Spring 与 JSF 结合使用来管理对象的关系和创建。
Spring 更像是一个完整的 j2ee 应用程序框架/平台。
Spring MVC 和 Web Flow 将帮助您设计类似于 JSF 的 Web 应用程序。
但是 Spring 以其 IOC 概念还带来了许多其他模块,例如依赖注入、aop、DAO、ORM、集成、批处理和社交工具等等。
您还可以检查 JSF-Spring 组合 - http://www.springsource.org/node/422
Spring and JSF are quite a different frameworks.
JSF is more of a web application framework and you can still use spring with JSF to manage the relationship and creations of the objects.
Spring is more of an entire j2ee application framework/plaform.
Spring MVC and web flow will help you to design web applications similar to JSF.
But spring with its IOC concept also brings a lot of other modules such as dependency injection, aop, DAO, ORM, integration, batch and social tools and much more.
You can also check the JSF-Spring combination - http://www.springsource.org/node/422
JSF是表示层,Spring是业务层(粗略的说),他们可以一起使用,并不竞争。
JSF is presentation layer, Spring business layer (roughly said), they can be used together and do not compete.
如前所述,JSF 是一个请求驱动的 MVC Web 框架,围绕轻量级 IoC 容器构建,旨在简化和标准化 Web 应用程序 UI 层的构建方式。
另一方面,Spring 不太关心 UI 层,但它的精确定义很难制定。可以说,SF 的主要功能是以标准化的方式将 Web 应用程序的不同层联系在一起,同时从开发人员那里抽象出特定 Web 技术的实现细节。结果之一是,开发人员无需实现“管道”,而是获得了相对容易测试、实现和使用的工作模块互连。这应该会提高生产力并缩短开发周期。
这种抽象可以通过各种 Spring 模块来查看 - Spring 是高度模块化的,因此您可以选择要使用框架的哪些组件。虽然它具有 MVC 框架(SpringMVC 主要是作为对 Jakarta Struts 的反应而编写的,Spring 开发人员认为 Jakarta Struts 编写得很差),但 Spring 缺乏专用的表示模块,因此您可以自由地使用大多数现有的 UI 技术(例如 JSF、 GWT-oids 等) - 一旦您在 Spring 中正确配置了它们。
换句话说,JSF 和 Spring 的“范围”有很大不同(尽管不是完全分离)。
As said before, JSF is a request-driven, MVC web-framework, built around a light-weight IoC container and is designed to simplify and standardize the way UI-layer of a web-application is built.
Spring, on the other hand, is less concerned with UI-layer but its precise definition is hard to formulate. It can be said that the primary function of SF is to tie together different layers of a web application in a standardized way, at the same time abstracting away the implementation details of a particular web technology from the developer. As one of the consequences, the developer is freed from implementing "plumbing" and instead gets working module interconnections which are tested, implemented and used relatively easily. This should provide a boost to productivity and shortens development cycle.
This abstraction can be viewed through various Spring modules - Spring is heavily modularized, so you choose which components of the framework will you be using. Though it features a MVC framework (SpringMVC is mostly written as a reaction to the Jakarta Struts, whom the Spring developers deemed poorly written), Spring lacks a dedicated presentation module so you're free to use most of existing UI technologies (e.g. JSF, GWT-oids, etc.) - once you properly configure them in Spring.
In another words, the "scopes" of JSF and Spring are quite different (though not totally disjunct).