Velocity 与 Apache Tiles

发布于 2024-10-16 19:59:13 字数 101 浏览 4 评论 0原文

什么更好? 我们将开始一个新的网络项目,这是选择哪种技术的问题。 项目包括Spring MVC + WebFlow。 在支持、扩展、性能方面有什么好的/坏的经验吗?

谢谢。

What's better?
We are going to start a new web project and it's a question which technology to choose.
Project includes Spring MVC + WebFlow.
Any good/bad experience in support, extending, performance?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

痴梦一场 2024-10-23 19:59:13

Velocity 和 Tiles 是两种不同的野兽——Tiles 是布局引擎,而 Velocity 是模板引擎。它们在功能上没有任何交叉点。

从你的问题我可以猜测你可能不会使用JSP。这是一个明智之举。 Velocity 是模板引擎之一,它的工作非常出色。

如果您选择遵循模板引擎路线进行视图,请查看commentit。这是我创建的一个小型、简单且快速的布局引擎。它可能完美地满足您的目的。

Velocity and Tiles are two different beasts — Tiles is a layout engine and Velocity is a template engine. They do not intersect anywhere in terms of functionality.

From your question I can guess you probably won't be using JSP. That's a smart move. Velocity is one of the template engines out there and it does an absolutely splendid job.

And if you choose to follow the template engine route for your view, then check out commentit. It's a small, simple and fast layout engine I created. It might serve your purpose perfectly.

将军与妓 2024-10-23 19:59:13

您想如何比较 Tiles 和 Velocity? - Tiles是一种组合页面片段的方式,而Velocity是一个更完整的模板引擎,比Tiles更好地与JSP相媲美。

无论如何:我将 Spring MVC 与 Tiles 和 JSP 一起使用:它工作得很好,节省了大量时间(仅使用 JSP,或 JSP 与 Sitemash),而且我没有注意到任何性能问题。 (但 Web 应用程序从未在高负载下使用过。)

How do you want compare Tiles with Velocity? - Tiles is a way to compose page fragments, while Veleocity is a more complete template engine, better comparable with JSP than Tiles.

Anyway: I used Spring MVC with Tiles and JSP: It worked greatly, saved a lot of time (toward just using JSP, or JSP with Sitemash), and I did not noticed any performance problems. (But the web application was never used under high load.)

望笑 2024-10-23 19:59:13

如果您想将一些单独的 HTML 文件放在模板中(即,您有一个单独的页眉、页脚、侧边栏页面,并且您想要将它们放在一起并以类似报纸的格式展示)。

如果您想从 Java 后端引入动态内容并将这些值注入到完整的 HTML 页面(即您有一个 < code>HTML 表来显示选定的汽车,并且所有汽车都存储在数据库中,使用 JPA,您可以从数据库中获取汽车数据,并将其存储到数据库中。在 EJB Bean、Spring @Component 或类似组件中维护的 List 然后,使用 Velocity,您可以将该信息存储为Map 中的存储桶项,并使用 VTL 标记引用 Map 中的键值项,以便可以渲染它们作为 HTML 响应的一部分,

为了实现上述目的,Velocity 将自己定位为一个完全的 Front Controller Servlet,或者由另一个 MVC 框架包装(即 Spring MVC 提供了一个 View Resolver,它包装了由 提供的功能)。 Velocity Servlet)。

HTML 请求通过 web.xml 配置定向到 Velocity Servlet 或替代 MVC 框架 Servlet。作为 servlet 响应的一部分,您的预烘焙 HTML 视图(带有 Velocity VTL 标记)会通过 Map 数据进行丰富。

简而言之,

Velocity 与 JSP 在同一领域展开竞争。

Tiles 更类似于页面嵌入。在 PHP 领域,Smarty 是一个很受欢迎的表兄弟。

您无法在它们之间进行选择,但很可能两者都使用。

Use Tiles if you have some seperate HTML files that you want to bring together in a Template (i.e. you have a seperate page for a Header, Footer, Sidebar and you want to bring them together and display them in a sort of Newspaper-like format).

Use Velocity if you want to bring dynamic content across from a Java backend and inject those values into a full HTML page (i.e. you have a HTML table to display a selection of Cars, and all of your cars are stored in a Database. Using JPA, you could get that Car data out of the database, and into a List<Car> maintained in an EJB Bean, Spring @Component, or similar. Then, using Velocity, you can store that information as the bucket item inside a Map, and use the VTL mark-up to refer to the key value items in the Map so that they can be rendered as part of the HTML response.

To achieve the above, Velocity positions itself as an outright Front Controller Servlet, or is wrapped by another MVC framework (i.e. Spring MVC provides a View Resolver which wraps the functionality provided by a Velocity Servlet).

HTML requests are directed to the Velocity Servlet or alternative MVC Framework Servlet via web.xml configuration. As part of the servlet response, your pre-baked HTML view, complete with Velocity VTL mark-up, is enriched with Map data.

Effectively, and in summary:

Velocity competes in the same space as JSP.

Tiles is more akin to page transclusion. In the PHP space, Smarty is a popular cousin.

You don't choose between them, but very well could use both.

挽清梦 2024-10-23 19:59:13

Tiles 2.2 有一个 Velocity 插件,因此您可以同时使用两者 - 通过 Velocity,您将访问上下文并像 JSP 一样动态构建您的积木,而tiles会将您的网站积木组合在一起。然而,Tiles 不允许做很多事情(至少我还没有发现它们),并且与 Spring 或 JSF 等文档相比,它的文档非常陈旧且糟糕。所以你可以考虑使用不同的技术。

我当前的项目中有 Tiles 参考,因为 Roo 为我做了它,但现在我将所有内容都转移到 JSF。

There is a Velocity plugin for Tiles 2.2 so you can use both - with velocity you will access context and build your bricks dynamically like with JSP and tiles will combine your website bricks together. However Tiles is not allowing to do many thigns (at least I haven't discovered them yet) and its documentation is very old and bad compared to for example Spring or JSF one. So you can consider using different technology instead.

I have Tiles references in my currect project because Roo did it for me but right now I'm moving everything to JSF.

仄言 2024-10-23 19:59:13

两者都用。 Tiles 和 Velocity 集成得很好,可以解决不同的问题。您可以使用 Velocity 的 #include 和 #parse 指令做一些类似 Tiles 的事情,但 Tiles 在组合方面做得更好。

Use both. Tiles and Velocity integrate very well and solve different problems. You can do some Tiles-ish stuff with Velocity's #include and #parse directives, but Tiles does that composition stuff better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文