`
gaojingsong
  • 浏览: 1182049 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

【Apache 之Velocity介绍】

阅读更多

What is Velocity?

Velocity is a Java-based template engine. It permits anyone to use a simple yet powerful template language to reference objects defined in Java code.

 

When Velocity is used for web development, Web designers can work in parallel with Java programmers to develop web sites according to the Model-View-Controller (MVC) model, meaning that web page designers can focus solely on creating a site that looks good, and programmers can focus solely on writing top-notch code. Velocity separates Java code from the web pages, making the web site more maintainable over its lifespan and providing a viable alternative to Java Server Pages (JSPs) or PHP.

 

Velocity's capabilities reach well beyond the realm of the web; for example, it can be used to generate SQL, PostScript and XML from templates. It can be used either as a standalone utility for generating source code and reports, or as an integrated component of other systems. For instance, Velocity provides template services for various web frameworks, enabling them with a view engine facilitating development of web applications according to a true MVC model.

 

The Apache Velocity Project

Velocity is a project of the Apache Software Foundation, charged with the creation and maintenance of open-source software related to the Apache Velocity Engine. All software created at the Velocity project is available under the Apache Software License and free of charge for the public.

 

 

Velocity是一个基于java的模板引擎(template engine)。它允许任何人仅仅使用简单的模板语言(template language)来引用由java代码定义的对象。

 

Velocity的能力远不止web站点开发这个领域,例如,它可以从模板(template)产生SQL和PostScript、XML,它也可以被当作一个独立工具来产生源代码和报告,或者作为其他系统的集成组件使用。Velocity也可以为Turbine web开发架构提供模板服务(template service)。Velocity+Turbine提供一个模板服务的方式允许一个web应用以一个真正的MVC模型进行开发。

 

使用Velocity基本步骤

1 initialize an engine

2 create a context and put data into it

3 choose a template and merge it

 

Velocity 不仅仅被用在了 MVC 的架构中,还可以被用在以下一些场景中。

1.Web 应用:开发者在不使用 JSP 的情况下,可以用 Velocity 让 HTML 具有动态内容的特性。

2. 源代码生成:Velocity 可以被用来生成 Java 代码、SQL 或者 PostScript。有很多开源和商业开发的软件是使用 Velocity 来开发的。

3. 自动 Email:很多软件的用户注册、密码提醒或者报表都是使用 Velocity 来自动生成的。使用 Velocity 可以在文本文件里面生成邮件内容,而不是在 Java 代码中拼接字符串。

4. 转换 xml:Velocity 提供一个叫 Anakia 的 ant 任务,可以读取 XML 文件并让它能够被 Velocity 模板读取。一个比较普遍的应用是将 xdoc 文档转换成带样式的 HTML 文件。

0
0
分享到:
评论

相关推荐

    apache velocity介绍及资料

    Apache Velocity 是一个开源的Java模板引擎,它允许开发者将HTML、XML或者其他格式的文档与应用程序逻辑分离。...对于初学者来说,这是一个非常有价值的资源,能够帮助快速上手并熟练运用Apache Velocity。

    Mastering.Apache.Velocity

    本书不仅介绍了 Velocity 的核心概念和技术细节,还提供了大量的实践案例和最佳实践,帮助读者快速掌握并运用 Velocity 技术于实际项目中。对于想要深入了解 Velocity 的开发者来说,这本书是非常有价值的参考资料。

    org.apache.velocity_1.3.1 jquery 插件

    在标题中提到的"org.apache.velocity_1.3.1"是Velocity的一个特定版本,即1.3.1版,发布于2005年,它提供了许多增强的功能和改进。 Velocity 1.3.1 版本主要特点包括: 1. **模板语言**:Velocity 使用其自己的模板...

    com.springsource.org.apache.velocity.tools.view-1.4.0.jar

    jar包,官方版本,自测可用

    Apache-Velocity

    apache-velocity提供了强大了模板引擎功能,为我们动态生成代码及代码片段提供了很好地支持,本资源包含了velocity使用文档及相应的jar包

    Mastering Apache Velocity

    《Mastering Apache Velocity》这本书是深入理解Apache Velocity这一强大模板引擎的权威指南。Apache Velocity是一个开源的Java模板引擎,它允许开发者将应用的展示层与业务逻辑层分离,从而提高开发效率和代码可...

    velocity-engine-core-2.3-API文档-中英对照版.zip

    Maven坐标:org.apache.velocity:velocity-engine-core:2.3; 标签:core、apache、engine、velocity、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...

    com.springsource.org.apache.velocity-1.5.0.jar

    jar包,官方版本,自测可用

    Apache Velocity - Velocity User Guide

    这一章节介绍 Velocity 模板语言的基础概念,包括语法特点和基本用法。VTL 是一种专为 Velocity 设计的轻量级脚本语言,旨在简化模板设计和动态内容生成过程。 #### 六、你好 Velocity 世界!(Hello Velocity ...

    velocity-site:Apache Velocity网站

    Apache Velocity项目Apache Velocity网站介绍当您访问 (我们的主页)时,将获得Apache Velocity网站。 它是所有Apache Velocity子项目的信封站点。 简而言之:仅当您感兴趣时,此Git存储库才对您很有趣a)想要在...

    Apache Velocity - Developer's Guide

    ### Apache Velocity - 开发者指南 #### 一、简介与入门 Apache Velocity 是一个基于 Java 的模板引擎,它提供了一种简单而强大的方法来创建和渲染格式化数据的文档。Velocity 的设计目的是使得开发者能够轻松地将...

    Apache Velocity - VTL Reference

    Apache Velocity - VTL Reference just for convenience, it's from official site documentation

    velocity所需的jar包

    `commons-collections.jar`和`commons-lang.jar`是Apache Commons项目的一部分,它们为Java开发提供了额外的集合操作和通用语言工具。这两个库是Velocity的依赖,因为它们提供了一些 Velocity在处理数据和模板逻辑时...

    velocity简介

    ### Velocity简介与精确解析 **Velocity**是一种基于Java的模板引擎,主要用于动态页面的生成,尤其是在Web应用开发中。它允许开发人员将业务逻辑与显示层分离,使得代码更加清晰和易于维护。Velocity通过简单的...

    velocity-tools-2.0.jar

    velocity-tools-2.0.jar velocity-tools-2.0.jar velocity-tools-2.0.jar velocity-tools-2.0.jar velocity-tools-2.0.jar

    velocity-tools-generic-3.1-API文档-中英对照版.zip

    Maven坐标:org.apache.velocity.tools:velocity-tools-generic:3.1; 标签:apache、velocity、tools、generic、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,...

Global site tag (gtag.js) - Google Analytics