各种 Java Web 表示层技术的优缺点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/538550/
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-10-29 12:47:24  来源:igfitidea点击:

Pros and Cons of Various Java Web Presentation Layer Technologies

javajakarta-eepresentation-layer

提问by rtperson

I'm currently working on a web app that makes heavy use of JSF and IceFaces. We've had some discussions of moving to another presentation layer, and I thought I'd take the discussion out into SO and see what the experts think.

我目前正在开发一个大量使用 JSF 和 IceFaces 的网络应用程序。我们已经就转移到另一个表示层进行了一些讨论,我想我会将讨论放到 SO 中,看看专家们的想法。

I'm curious if anyone could weigh in on the pros and cons of the various Java presentation layer technologies. If you've only worked with one, say why you love it or hate it. If you've worked with several, give your impressions of how they stack up against each other.

我很好奇是否有人可以权衡各种 Java 表示层技术的优缺点。如果您只与其中一家合作过,请说出您喜欢或讨厌它的原因。如果您曾与多个合作过,请给出您对它们如何相互叠加的印象。

Our technologies under consideration are:

我们正在考虑的技术是:

  • IceFaces
  • JSF (without IceFaces)
  • GWT (Google Web Toolkit)
  • Wicket
  • Tapestry
  • 冰面
  • JSF(没有 IceFaces)
  • GWT(谷歌网络工具包)
  • 便门
  • 挂毯

And if I'm missing anything from my list, let me know.

如果我遗漏了清单中的任何内容,请告诉我。

Thanks!

谢谢!

采纳答案by Esko

My opinions are quite heavily biased towards Wicket because I've been using it for a while after tripping over JSP mines far too many times.

我的观点非常偏向 Wicket,因为在多次被 JSP 矿坑绊倒后我已经使用了一段时间。

Wicket PROs:

Wicket PRO:

  • True separation of layout and code.
  • Component based which means high reusability of site elements; For example you can create prettified form with automatic labeling and CSS styles and everything and just by changing it's DAO object in the component's constructor it's completely reusable in another project.
  • Excellent support for things like Ajax, Portlets and various frameworks in general directly out-of-the-box AND more importantly it doesn't rely on anything else than slf4j/log4j to work, everything's optional!
  • 布局和代码的真正分离。
  • 基于组件,这意味着站点元素的高度可重用性;例如,您可以创建带有自动标签和 CSS 样式以及所有内容的美化表单,只需在组件的构造函数中更改它的 DAO 对象,它就可以在另一个项目中完全重用。
  • 对 Ajax、Portlets 和各种框架等事物的出色支持,通常直接开箱即用,更重要的是,它不依赖于 slf4j/log4j 之外的任何其他东西,一切都是可选的!

Wicket CONs:

检票口缺点:

  • Development has some confusion about things in general and Wicket generics are a bit of a mess right now although they've been cleaned a lot in 1.4
  • Some components (like Form.onSubmit()) require extensive subclassing or anonymous method overriding for injecting behaviour easily. This is partly due to Wicket's powerful event-based design but unfortunately it also means it's easy to make a code mess with Wicket.
  • 开发对一般事物有些混乱,Wicket 泛型现在有点混乱,尽管它们在 1.4 中已经被清理了很多
  • 某些组件(如Form.onSubmit())需要广泛的子类化或匿名方法覆盖才能轻松注入行为。这部分是由于 Wicket 强大的基于事件的设计,但不幸的是,这也意味着很容易用 Wicket 弄乱代码。

Random CONs:(that is, I haven't used but these are my opionions and/or things I've heard)

随机缺点:(也就是说,我没有使用过,但这些是我的观点和/或我听说过的东西)

  • GWT is JavaScript based which sounds stupid to me. Main issue is that it reminds me too much of JSP:s and its autogenerated classes which are horrible.
  • Tapestry doesn't separate markup and code properly in a manner which could be easily validated between the two which will cause problems in the future.
  • GWT 是基于 JavaScript 的,这对我来说听起来很愚蠢。主要问题是它让我想起了 JSP:s 及其自动生成的类,这些类太可怕了。
  • Tapestry 没有以一种可以在两者之间轻松验证的方式正确地分离标记和代码,这将在未来引起问题。

回答by Don Branson

I've used GWT for a couple small projects. Here are some things I like about it:

我已经将 GWT 用于几个小项目。以下是我喜欢它的一些地方:

  1. It's ajax by default, so I didn't have to makeit do ajax, it just came along with using GWT.
  2. It's got good separation of client versus server-side code.
  3. I can unit-test my client code using junit
  4. It lets you built crisp, snappy apps, largely because it's ajax.
  1. 它的Ajax默认情况下,所以我没得它来做AJAX,它只是使用GWT走了过来。
  2. 它很好地分离了客户端和服务器端代码。
  3. 我可以使用 junit 对我的客户端代码进行单元测试
  4. 它可以让您构建清晰、活泼的应用程序,主要是因为它是 ajax。

Things I don't like:

我不喜欢的东西:

  1. Some things don't work as expected. For example, I've seen cases where click events didn't fire as expected, so I had to do a workaround.
  2. Auto-deploy to tomcat running in eclipse sometimes just stops working, and I could never figure out why.
  1. 有些事情没有按预期工作。例如,我见过点击事件没有按预期触发的情况,所以我不得不做一个解决方法。
  2. 自动部署到在 eclipse 中运行的 tomcat 有时会停止工作,我永远不知道为什么。

回答by Stephane Grenier

The biggest question I'd ask is why are you changing presentation layer? That's a very expensive cost and I can see the benefits of one technology outweighing the others by as much as the cost to change...

我想问的最大的问题是你为什么要改变表现层?这是一个非常昂贵的成本,我可以看到一种技术的好处超过其他技术的好处与改变的成本一样多......

回答by Dimitri De Franciscis

In short:

简而言之:

= JSF =

= JSF =

PROS:

优点:

  • component architecture;
  • many libraries & tools;
  • somewhat good IDE support
  • 组件架构;
  • 许多库和工具;
  • 有点不错的IDE支持

CONS:

缺点:

  • heavy weight, both in CPU/memory andlearning curve;
  • when something doesn't work as expected, it's difficult to debug
  • CPU/内存学习曲线都很重;
  • 当某些事情没有按预期工作时,就很难调试

= WICKET =

= 小门 =

PROS:

优点:

  • lightweight;
  • sensible templating system;
  • good tutorials;
  • 轻的;
  • 合理的模板系统;
  • 很好的教程;

CONS:

缺点:

  • reference documentation is not so well organized and deep as are the tutorials;
  • development team had some serious difficulties, especially when becoming and incubated project. This lead to confusion on important aspects of the framework, at that time I had to switch to another framework because of this...
  • 参考文档不像教程那样有条理和深入;
  • 开发团队遇到了一些严重的困难,特别是在成为和孵化项目时。这导致对框架重要方面的混淆,当时我不得不切换到另一个框架因为这个......

回答by A_M

What about Stripes?

怎么样条纹

回答by Franklin

My pick would be Wicket. Have used it and is gives excellent re-usability. It has one of the most vibrant forum/mailing list. As a question and its gonna be answered in minutes. It has excellent support for AJAX. One of the usual cons attributed to Wicket is the steep learning curve. Well those were one of the old age cons which hold no value anymore now.

我的选择是Wicket。使用过它并提供了出色的可重用性。它拥有最活跃的论坛/邮件列表之一。作为一个问题,它会在几分钟内得到回答。它对 AJAX 有很好的支持。Wicket 的常见缺点之一是陡峭的学习曲线。好吧,那些是现在不再有价值的旧式缺点之一。

JSF: Better stay away from it. Another team which developed a project on JSF is now thinking to shift to Wicket after our success with it.

JSF:最好远离它。另一个在 JSF 上开发项目的团队现在正在考虑在我们成功后转向 Wicket。

@Megadix: Like you said the documentation was poor in the beginning, but not any more. There is an excellent book called Wicket in Action written by the developers of Wicket. The sample code provided on the site is also a good place to start and learn

@Megadix:就像你说的,一开始文档很差,但现在不是了。Wicket 的开发人员编写了一本名为 Wicket in Action 的优秀书籍。站点上提供的示例代码也是开始和学习的好地方

回答by Sergey

See my comparison of Wicket and Tapestry 5: Difference between Apache Tapestry and Apache Wicket.

请参阅我对 Wicket 和 Tapestry 5 的比较:Apache Tapestry 和 Apache Wicket 之间的区别

回答by duffymo

I'd wonder if you a have a service layer that's distinct from the web client, something that the web controllers simply invoke to get their work done.

我想知道您是否有一个不同于 Web 客户端的服务层,Web 控制器只需调用它来完成他们的工作。

If you do, the choice of web UI technology can be decoupled from the back end. If it's exposed as a contract first web service, you can have different apps share it. As long as your clients can send and receive XML they can interact with your services. Want to switch to Flex? No worries - point it at the service and render the XML response.

如果这样做,Web UI 技术的选择可以与后端解耦。如果它作为合同优先的 Web 服务公开,您可以让不同的应用程序共享它。只要您的客户可以发送和接收 XML,他们就可以与您的服务进行交互。想切换到 Flex?不用担心 - 将其指向服务并呈现 XML 响应。