Wicket 还是 Playframework?
我对 Java Web 开发完全陌生,我想选择一个好的 Java Web 框架来学习。我发现了一些关于 Apache Wicket 框架 和 Play 框架。我决定选择其中之一;但我需要选择;-)
那么,选择什么以及为什么?
编辑
我的要求:
- 我有很好的使用 Django 开发经验,所以类似的框架会很棒,
- 我需要一个可以与其他主流 Java 好东西(库、工具等)交互的框架,所以我可以利用 Java 真正提供的功能。
I'm totally new to Java web development and I would like to choose a good Java web framework to learn. I've found some really good echoes regarding the Apache Wicket framework and the Playframework. I decided to go for one of 'em; but I need to choose ;-)
So, what to choose and why?
EDIT
My requirements:
- I had a good experience developing with Django, so a similar framework would be great,
- I need a framework that can interact with other mainstream Java goodies (libraries, tools ..etc) so I can take advantage of what Java does really offer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Wicket 和 Play 是两种截然不同的框架。
Play 是一个 MVC 框架,您可能会对它来自 Django 感到熟悉。与 Django 一样,它不仅仅提供 Web 位,还提供基于 JPA 的 ORM 框架、脚手架工具以及可能更多(我没有这方面的实际经验)。他们的网站上有一个很棒的教程,您可能会在那里看到 Django 的相似之处。
Wicket 是一个面向组件的框架(如 JSF 和 Tapestry),并且重点关注面向对象的设计。它本身也是 MVC,但页面通常是通过组合独立且可重用的组件(视图和控制器、可插入模型)来构建的。这些组件可以通过标准继承和组合进行扩展,并且标记与代码非常清晰地分离并且易于修改。
Wicket 可以自动管理事件回调和状态,因此无论您的页面多么复杂,您都无需考虑网址。一个可点击按钮在点击时消失的简单示例(非常有用):
我想强调的是,您不必使用服务器端状态,并且很可能将 Wicket 用作“普通”MVC如果你愿意的话,可以使用框架(是的,很容易获得漂亮的网址)。
Wicket 项目仅关注核心 Web 框架,没有额外的“细节”,例如特殊的 ORM 支持或脚手架。我个人同意 Wicket 项目的理念,但对于使用该框架的新开发人员来说,做可排序和可分页表等“简单”的事情可能有点令人畏惧,因为预构建的组件有点稀缺。 Wicket 的学习和生产力曲线可能有点陡峭,但好处是,一旦您制作了适合您需求的组件(和“行为” - 更长的故事),它们就非常可重用。
虽然我个人很喜欢 Wicket,但我有预感,Play 可能会是最好的选择。你的问题表明你想要一个可以访问Java库的“Django”,在这种情况下,我认为Play(或其他一些Java MVC)是安全的选择。另一方面,也许您一直在使用 Django,因为您不知道 Wicket 有多么强大。 ;) 如果您提供有关您的项目的更多信息,我们将能够给出更合格的答复。
作为一个辅助节点:由于 Play 不是很主流(至少目前如此),我还会考虑 Grails 拥有强大的商业支持和更多开箱即用的模块。
Wicket and Play are two very different types of frameworks.
Play is a MVC framework which you probably will feel familiar with coming from Django. Like Django, it offers more than just the web bits and provides a JPA based ORM framework, scaffolding tools and probably a lot more (I have no practical experience with it). They have a great tutorial on their site, and you'll probably see the Django similarities there.
Wicket is a component oriented framework (like JSF and Tapestry) and focuses heavily on object oriented design. It's also MVC, per se, but pages are usually built by composing self-contained and reusable components (View and Controller, pluggable Models). These components can be extended by standard inheritance and composition and markup is very cleanly separated from code and easily modified.
Wicket can manage event callbacks and state automatically, so that you don't have to think urls at all, no matter how complex your page is. A quick example for a clickable button that goes a away when it's clicked (very useful):
I want to emphasize that you don't have to use server-side state, and that it's quite possible to use Wicket as a "normal" MVC framework if you want to (and yes, it's easy to get pretty urls).
The Wicket project focuses only on the core web framework and there are no extra "niceties" such as special ORM support or scaffolding. I personally agree with the Wicket project's philosophy here, but for new developers coming to the framework, doing "simple" stuff such as a sortable and pageable table can be a bit daunting as pre-built components are a bit scarce. The learning and productivity curve for Wicket can be a bit steep, but the upside is that once you've made components (and "behaviours" - longer story) that fit your needs, they are extremely reusable.
Although I personally love Wicket, I have a hunch that you probably will be best off with Play. Your question indicates that you want a "Django" with access to Java libs, and in that case I think Play (or some other Java MVC) is the safe choice. On the other hand, maybe you've been using Django because you didn't know how incredibly powerful Wicket is. ;) If you give some more info on your project, we'll be able to give a more qualified response.
As a side-node: As Play is not very mainstream (at least for now), I'd also consider Grails which has strong commercial backing and even more out-of-the-box modules.
玩!旨在让来自 Python 和 PHP 等脚本语言的开发人员感到舒适。它提供了自己的构建系统和管理脚本,有点像 Rails 或 Django。现有的构建工具和基础设施(例如 Java 领域中常用的依赖管理的 Maven 存储库)将无法与 Play 很好地集成。
对于来自 Java 桌面开发的开发人员来说,Wicket 将会更加舒适。它不提供特殊的工具,因此如果您有偏好,那么集成到特定的构建工具中会更容易(并且有许多构建工具提供了 Java 生态系统中可用的自动依赖项检索等功能。)
所以有很大的区别在这两个选项之间:)如果您能弄清楚哪种经历对您最有利,那么您的决定就应该很清楚了。
Play! is designed to be comfortable for developers coming from scripting languages like Python and PHP. It provides its own build system and management scripts, somewhat like Rails or Django would. Existing build tools and infrastructure (like the Maven repositories commonly used for dependency management in Java-land) will not integrate well with Play.
Wicket will be more comfortable for developers coming from desktop development in Java. It doesn't provide special tooling, so it will be easier to integrate into a specific build tool if you have a preference (and there are many build tools providing things like automated dependency retrieval available in the Java ecosystem.)
So there's quite some difference between the two options :) If you can figure out which experience would benefit you most, the decision should be pretty clear from there.
如果您的系统仅适用于 Web 层,那就玩吧!框架非常合适。
但是
,如果您的数据模型不仅仅用于 Web,可能通过 Spring 使用 CXF 将其导出为 REST
,并由 GWT 或其他 Web 服务使用,并且您想要确保与 Web 层保持一致,Wicket(带有 Spring/hibernate)是一个不错的选择。我对 Play 感觉不太好!是缓存机制。您必须手动命名/插入/检索/无效/清除缓存。这将使整个架构容易出错。当 wicket 使用 spring/JPA(hibernate)/ehcache(或其他提供程序) 时,您可以为上层 (web/REST...) 定义一致的缓存/dao 层,这不会造成状态不一致。
wicket 的另一个优点是它具有由 Java 支持的内置 AJAX 支持。虽然这些 AJAX 的状态是在服务器端维护的(可能有点迟缓),但如果你不想学习 JavaScript,你仍然可以构建一个“还不错”的 AJAX 页面。
与玩! ,如果你不懂JS,也不想学它,不想操作繁琐的DOM,那么你只能建立一个‘一般’的网站。 OTOH,如果你熟练使用 JS / jQuery,你可以选择 Play! 。
If your system is only for Web tier , Play! framework is very suitable.
But
, if your data models are not just for web , maybeexported as REST by Spring with CXF
, and consumed by GWT or other web services , and you want to make sure the consistent states with web tier , Wicket (with Spring/hibernate) is a good choice.Something I don't feel so good about Play! is the caching mechanism. You have to manually naming/insert/retrieve/invalidate/purge cache . This will make the whole architecture error-prone. While wicket with spring/JPA(hibernate)/ehcache(or other providers) , you can define consistent caching/dao layer for upper layer (web/REST...) , which will not impose state inconsistencies.
Another advantage with wicket is it has built-in AJAX support backed by Java . Although these AJAX's states are maintained in the server side (and maybe a little sluggish) , if you don't want to learn JavaScript , you can still build a 'not-so-bad' AJAX page .
With Play! , If you don't know about JS , and don't want to learn it , don't want to manipulate cumbersome DOMs , you can only build an 'average' site. OTOH , if you are skilled with JS / jQuery , you can choose Play! .
我正在使用播放!很多,并使用 Wicket 进行了一些评估。
我的经验是,您必须编写更多代码才能使用 Wicket 完成相同的工作。与 Wicket 相比,您有更多的“间接性”。我个人更喜欢具有尽可能少的“仪式”并且易于遵循的代码。
戏剧!架构师还为 Play! 添加了 Scala 支持,我认为这是一个好主意,因为 Scala 可以与 Java 代码和库完全互操作,而且比 Java 先进得多。
I'm using PLay! a lot and have used Wicket for a bit of evaluation.
My experience is, that you have to write a lot more code to get the same work done with Wicket. You have more "indirection" with Wicket. I personally prefer code that has as little as possible "ceremony" and that is easy to follow.
The Play! architects are also adding Scala support to Play!, which I think is a great idea, since Scala is fully interoperable with Java code and libraries but by far more advanced then Java.