使用 Servlet/JSP 或其他前端框架的 JSF 或 MVC?
我正在使用 Java 开发社交网络应用程序。我需要为网络浏览器开发应用程序的前端/GUI。
我想知道进行前端开发的更好策略是什么,是否使用像 JSF 2.0 和 JSF 2.0 这样的框架。喜欢或简单地遵循带有 servlet 和 JSP 的 MVC 方法?
我听说 JSF 确实使开发变得更简单,但学习曲线也不太低,那么值得学习 JSF 还是我应该直接继续使用 servlet/JSP?
我是使用 Java 进行 Web 应用程序开发的新手我几乎已经完成了应用程序业务逻辑的编写。
请根据以下参数证明您的答案:
- 性能与性能成本
- 易于开发和使用时间(也考虑学习时间)
- 代码的未来维护
- 您认为重要的任何其他参数
更新(07-09-2012):
我最终选择了 JSF-2.0 和 JSF-2.0。迄今为止没有遗憾。学习曲线并不陡峭。这更容易&使用 Primefaces 等组件库,开发速度很快。国家储蓄会产生一些成本,但这些事情可以明智地处理。社区很大&现在事情都有据可查。希望在不久的将来,无状态 JSF 也会出现,这将提高 JSF 的超高性能。
I'm working on development of a social web application using Java. I need to develop the frontend/GUI of my application for web browsers.
I'm wondering what is the better strategy to do frontend development, whether using frameworks like JSF 2.0 & like OR simply following MVC approach with servlets and JSPs ?
As I have heard JSF really makes the development simpler but also the learning curve is not too low, so is it worth learning JSF or I should prefer to directly proceed with servlets/JSPs ?
I'm new to web applications development using Java & I've almost completed writing the business logic for the application.
Please justify your answer on the basis of following parameters:
- Performance & costs
- Ease of Development & Time (considering the learning time as well)
- Future Maintenance of code
- Any other parameters you consider important
Update (07-09-2012):
I finally went with JSF-2.0 & have no regrets till date. Learning curve is not steep. It's easier & development is fast with component libraries like Primefaces. There are some costs as to state saving but those things can be handled intelligently. Community is big & things are well documented now. Hopefully, in near future Stateless JSF is also coming which will boost JSF with extra high performance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于一个爱好 Web 应用程序来说,自制一些 MVC 框架也不错。这是一次很好的学习锻炼之旅。然而,从长远来看,如果你在网络上发布并且它变得流行,它肯定会对你产生影响。大多数现有的 MVC 框架都经过深思熟虑。大多数不可预见的警告都被考虑在内。唯一的框架 API 由第三方良好维护和记录。
此外,每当您的 Web 应用程序变得流行并且您需要更多开发人员来开发它来满足最终用户的要求/愿望时,就更容易找到已经熟悉现有框架的人。使用自制且可能存在缺陷的 MVC 框架,您可能会发现更少的开发人员在接管维护工作之前急于进入另一个学习曲线,而他们可能永远不会在未来的工作/项目中重新应用这些维护工作。
这并不特别适用于 JSF,也适用于所有其他现有的流行 MVC 框架,例如 Spring MVC。至于一般的 JSF,我之前已经写过很多相关内容。以下是阅读相关内容的一些很好的起点:
For a hobby webapp, homebrewing some MVC framework is not bad. It's a nice learning exercise tour. However, it will bite you on the long term, for sure if you publish on the web and it becomes popular. Most of existing MVC frameworks are very well thought out. Most of the unforeseen caveats are taken into account. The sole framework API is well maintained and documented by a third party.
Also, whenever your webapp becomes popular and you need more developers to work on it to fulfill the enduser requirements/wishes, it's easier to find someone who's already familiar with an existing framework. With a homebrewed and possibly buggy MVC framework, you'll likely find less developers who are eager enough to dive into another learning curve before taking over the maintenance which they'll probably never reapply on their future jobs/projects.
This does not specifically apply on JSF, but on every other existing and popular MVC framework as well, such as Spring MVC. As to JSF in general, well, I've written a lot about it before here. Here are some good starting points to read the one and other about it:
对于像您这样的现代网络应用程序,如果您的责任是 UI,那么您真的不希望在您和 html/css/javascript 之间有任何“抽象层”。不要使用任何“组件”框架。
您是否从在实际产品中实际使用 JSF 的真正 Web 应用程序开发人员那里听到过这样的话?或者只是 JSF 委员会拍拍自己的背?或者一些老手一厢情愿地认为他们不需要学习该死的 javascript?
如果您选择JSF,请在您沮丧地开枪后向我们报告您的经历。
For modern web apps like yours, and if your responsibility is the UI, you really don't want any "abstraction layer" stand between you and your html/css/javascript. Don't use any "component" framework.
Did you hear that from real webapp developers who actually used JSF in real products? Or just JSF committee patting their own backs? Or some old timers' wishful thinking that they don't need to learn the darn javascript?
If you choose JSF, please report your experience back to us after you shoot yourself out of frustration.
最好使用一些MVC框架。
您可以使用任一基于组件的框架:
Or you can use request oriented framework.
每个框架都有其优点和缺点,这取决于具体情况和您的知识。我无法给你单一值的答案。
It's better use some MVC framework.
You can use either component based framework:
Or you can use request oriented framework.
Each framework have its pro-and-con it depend on situation and your knowledge. I cannot give you single-valued answer.
Spring MVC 非常容易学习,如果您有一个简单的 Web 应用程序并且您想节省时间,那么它比 JSF 更好。
但是,如果您的 Web 应用程序不是那么简单,那么 JSF 远远胜过 Spring MVC。它的模型更复杂,但结构更好,并且得到广泛支持,因此在大多数情况下您不必再次重新发明轮子。复杂的 GUI 可以用 JSF 轻松完成。
Spring MVC is very easy to learn and if you have a simple web app and you want to save your time, its better than JSF.
However if your web app is not so simple, JSF beats Spring MVC by far. Its model is more complicated, but it is much better structured and it is widely supported, so that you don't have to reinvent the wheel again in most of the cases. Complex gui can done with JSF with less effort.
如果您正在探索选项,您可能需要考虑 Tapestry 5。多年来,我们一直在社交媒体领域的一个大型项目中愉快地使用它。它是一个易于使用的基于组件的 MVC 框架。我们能够利用它快速开发,特别是现在我们已经构建了很多构建块。
学习时间可能与任何新框架的学习时间相当。我可能会说它比 JSF 少,比 Spring MVC 多,尽管这实际上取决于您已经熟悉的内容以及您使用事物的深度。不久前,我在 github 上整理了一个非常小的项目,以便快速开始使用 Tapestry 5,如果您感兴趣,它是 tapstack 。
至于长期使用基于 Tapestry 的应用程序,它对我们很有帮助。代码的维护性已经比使用JSP时好很多了。它也非常稳定。我们通过 Tapestry 提供了数十亿的页面浏览量,没有出现任何重大问题。
缺点是它不像其他一些 Web 框架那么常见。这肯定也有点不同。我们觉得这是值得的,而且合作起来令人耳目一新。最终,这将取决于您的需求以及您认为最适合您的方式。祝你的决定好运。
You might want to consider Tapestry 5 if you're exploring options. We've been happily using it for many years on a large project in the social media space. It's an easy to use MVC framework that's component based. We're able to develop rapidly with it, especially now that we've built up a lot of our building blocks.
Learning time is probably on par with ramping up on any new framework. I'd perhaps say it's less than JSF and more than Spring MVC, though it really depends on what you're already familiar with and how deeply you use things. I put together a very small project on github a while back to get started with Tapestry 5 quickly, if you're interested it's tapstack.
As for long term use of a Tapestry based application, it has served us well. Maintenance of the code has been much better than when were using JSP. It's very stable as well. We've served billions of page views through Tapestry without any major problems.
On the downside it is less common than some other web frameworks. It is definitely a little different too. We feel it's worth it though, and refreshing to work with. Ultimately it's going to depend on what you need and what you feel works best for you. Best of luck with your decision.