Java Spring MVC 与 JSF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2249706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:13:43  来源:igfitidea点击:

Spring MVC vs JSF

javajsfspring-mvc

提问by Yatish

I haved used Struts framework in all my past applications and for the new application,my client has requested to use either Spring MVC or JSF? I am not familiar with these two frameworks but our timelines are strict. So, I am not sure which framework I will choose to build the application.

我在过去的所有应用程序中都使用了 Struts 框架,对于新应用程序,我的客户要求使用 Spring MVC 还是 JSF?我不熟悉这两个框架,但我们的时间表很严格。所以,我不确定我会选择哪个框架来构建应用程序。

Can anyone please suggest me which framework will be easy to learn in quick time?

任何人都可以建议我快速学习哪个框架?

Thanks

谢谢

采纳答案by Nate

Of course, it's going to be different for everyone, but I'd suggest Spring MVC, as it's a request-based framework like Struts. Of course, you'll want to learn about core Spring stuff like Inversion of Control / Dependency Injection (but I'd consider that a plus...) and whatever you're going to use for database access (just JDBC? Hibernate? iBatis? etc.).

当然,每个人都会有所不同,但我建议使用 Spring MVC,因为它是一个类似于 Struts 的基于请求的框架。当然,您会想了解 Spring 的核心内容,例如控制反转/依赖注入(但我认为这是一个加分项...)以及您将要用于数据库访问的任何内容(只是 JDBC?Hibernate? iBatis?等)。

JSF is component-based, which is a bit different paradigm from request-based frameworks. If you do plan to go the JSF route, I'd suggest looking at Seam from JBoss. It's more of a front-to-back framework that uses JSF as the web/presentation end and EJB as the backend. And pretty much all the people who've used it claim it makes JSF and EJB more usable than they are by themselves.

JSF 是基于组件的,这与基于请求的框架有点不同。如果您确实打算走 JSF 路线,我建议您查看 JBoss 的 Seam。它更像是一个使用 JSF 作为 web/presentation 端和 EJB 作为后端的从前到后的框架。几乎所有使用过它的人都声称它使 JSF 和 EJB 比它们本身更有用。

Good luck on whichever technology you choose, though. (Sounds like you'll need it - strict timelines and a client that's prescribing web frameworks?)

不过,无论您选择哪种技术,都祝您好运。(听起来您会需要它 - 严格的时间表和规定 Web 框架的客户端?)

回答by Bozho

I'd suggest SpringMVC, because of the timeframe:

由于时间安排,我建议使用 SpringMVC:

  • you need something with less steep learning curve. SpringMVC is more like Struts than JSF
  • in order to use the power of JSF you need to get familiar with many "tricks", while SpringMVC is more or less straightforward
  • 你需要学习曲线不那么陡峭的东西。SpringMVC 更像 Struts 而不是 JSF
  • 为了使用 JSF 的强大功能,您需要熟悉许多“技巧”,而 SpringMVC 或多或少是直接的

回答by Ted

I'd suggest JSF + Primefaces component library. I am using this combination to build most of our projects. As I remember, I spent one week to learn the technology and finished my first project in one month. The development time at least 30% faster than Struts.

我建议使用 JSF + Primefaces 组件库。我正在使用这种组合来构建我们的大部分项目。我记得,我花了一周时间学习这项技术,并在一个月内完成了我的第一个项目。开发时间至少比 Struts 快 30%。

SpringMVC is not a bad technology and it's quite popular.

SpringMVC 并不是一项糟糕的技术,而且非常流行。

Really depends on which one your like the most.

真的取决于你最喜欢哪一个。

回答by J Slick

Of course, you'll want to learn about core Spring stuff like Inversion of Control / Dependency Injection (but I'd consider that a plus...)

当然,你会想了解核心 Spring 的东西,比如控制反转/依赖注入(但我认为这是一个加分......)

JSF is indeed based on IoC, and much simpler than the Spring learning curve.

JSF 确实是基于 IoC 的,而且比 Spring 的学习曲线简单得多。

回答by Dhrumil Shah

JSF is just the view layer of the MVC and wil need to be used with other technologies like Spring/Hibernate or EJB for a full MVC.

JSF 只是 MVC 的视图层,需要与 Spring/Hibernate 或 EJB 等其他技术一起使用才能实现完整的 MVC。

I have been using the Spring MVC for about 1 months now, whilst it's probably not the latyest version of SpringMVC I've found it a little annoying that we have so much XML to deal with. All the managed beans and DAO has XML config to it. Also everything seems to have to go thorugh a method called onSubmit().

我已经使用 Spring MVC 大约 1 个月了,虽然它可能不是 SpringMVC 的最新版本,但我发现我们有这么多 XML 需要处理有点烦人。所有托管 bean 和 DAO 都有 XML 配置。此外,一切似乎都必须通过一个名为 onSubmit() 的方法。

JSF with something like EJB is far simplier in my opinion... Everything can be done using Annotations so simply use @ManagedBean=theBean in your backing bean and in your JSF put {thebean.param} and you have access to the backing bean's data. Also you can use the Session beans of your EJB as the backing beans for JSF then have direct acces to the DAO (Model layer) Entity bean. Again simply by using the @Entity annotation and the EntityManager class

在我看来,JSF 和 EJB 之类的东西要简单得多......一切都可以使用注释来完成,所以只需在你的支持 bean 中使用 @ManagedBean=theBean 并在你的 JSF put {thebean.param} 中,你就可以访问支持 bean 的数据. 您还可以使用 EJB 的会话 bean 作为 JSF 的支持 bean,然后直接访问 DAO(模型层)实体 bean。再次简单地通过使用 @Entity 注释和 EntityManager 类

Spring MVC is a web framework inside the Spring framework. It does provide features as those in JSF 2.0: ajax-support validation dependency-injection etc Yet, you can use Spring (not Spring MVC) together with JSF 2.0, with spring providing the dependency-injection, aop, transaction management mechanisms, and JSF providing the web layer.

Spring MVC 是 Spring 框架内的一个 web 框架。它确实提供了 JSF 2.0 中的特性:ajax 支持验证依赖注入等 然而,您可以将 Spring(而不是 Spring MVC)与 JSF 2.0 一起使用,spring 提供依赖注入、aop、事务管理机制和 JSF提供网络层。