`
able0001
  • 浏览: 28207 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

velocity 笔记

阅读更多

Single quotes will ensure that the quoted value will be assigned to the reference as is. Double quotes allow you to use velocity references and directives to interpolate, such as "Hello $name", where the $name will be replaced by the current value before that string literal is assigned to the left hand side of the =


#set( $a = "Velocity" )

单引号不解析 双引号解析

## This is a single line comment.

The Property $customer.Address has the exact same effect as using the Method $customer.getAddress()

<input type="text" name="email" value="$!email"/> !表示可为空 否则输出  $email

Now when the form is initially loaded and $email still has no value, an empty string will be output instead of "$email".

References to instance variables in a template are not resolved. Only references to the attribute equivalents of JavaBean getter/setter methods are resolved (i.e. $foo.Name does resolve to the class Foo's getName() instance method, but not to a public Name instance variable of Foo).

#[[don't parse me!]]#

<table>
#foreach( $customer in $customerList )
    <tr><td>$foreach.count </td><td>$customer.Name</td></tr>
#end
</table>

#foreach( $customer in $customerList )
    $customer.Name#if( $foreach.hasNext ),#end
#end

 $foreach.index    0开头
$foreach.first and $foreach.last

$foreach.parent or $foreach.topmost

#break

#include ----  The contents of the file are not rendered through the template engine.

The #parse script element allows the template designer to import a local file that contains VTL. Velocity will parse the VTL and render the template specified.

(e.g. #break($macro)). This will stop rendering of all scopes up to the specified one

#break($foreach.parent

The #stop directive stops any further rendering and execution of the template.
短路方式,render马上结束

The example below will display abc.

#set($source1 = "abc")
#set($select = "1")
#set($dynamicsource = "$source$select")
## $dynamicsource is now the string '$source1'
#evaluate($dynamicsource)


#define( $block )Hello $who#end
#set( $who = 'World!' )
$block
display Hello World!


Note that the range operator only produces the array when used in conjunction with #set and #foreach directives

分享到:
评论

相关推荐

    velocity笔记

    【Velocity模板语言(VTL)详解】 Velocity模板语言(Velocity Template Language, VTL)是Apache Velocity引擎的核心组成部分,设计用于在Web开发中分离表现层和业务逻辑。它的主要目的是让非程序员,尤其是网页设计...

    Velocity语法笔记

    ### Velocity 语法笔记 #### 一、Velocity 概述与基本用法 Velocity 是一个基于 Java 的模板引擎,主要用于 Web 应用程序中生成动态页面。它提供了丰富的语法支持,使得开发者可以更轻松地处理数据并将其转换为...

    velocity学习笔记

    ### Velocity学习笔记精要 **一、Velocity简介与特点** Velocity是一种基于Java的模板引擎,用于将静态数据和动态内容结合在一起,生成最终的HTML、XML或其他格式的文档。其最大的特点是性能高、易于理解和使用,...

    velocity学习笔记与struts2整合

    Velocity是Apache软件基金会的一个开源项目,它是一款快速、强大且易用的模板引擎,用于生成动态Web内容。在Java世界中,Velocity常被用来作为MVC框架中的视图层技术,与Struts2等框架集成,以实现更灵活的页面渲染...

    Velocity用户手册.pdf

    ### Velocity 用户手册中文版知识点概览 #### 一、Velocity 概述 - **定义**:Velocity 是一款基于 Java 的模板引擎(template engine),能够帮助开发者轻松地利用模板语言(template language)引用 Java 代码中...

    崔希凡javaweb28天笔记

    7. **模板引擎**:如FreeMarker或Velocity的使用,用于动态生成HTML页面。 8. **异常处理**:在Java Web中的全局异常处理机制,以及如何自定义异常类。 9. **安全问题**:如防止SQL注入、XSS攻击和CSRF攻击的策略...

    狂神说redis笔记

    大数据时代的特征可以概括为“3V+3高”,即海量的数据量(Volume)、多样化的数据类型(Variety)、快速的数据流(Velocity),以及高并发、高可扩展性和高性能等要求。 通过狂神的Redis笔记,我们可以系统地学习...

    张龙圣思园struts2学习笔记word

    在实际开发中,Struts2支持多种视图技术,如JSP、FreeMarker、Velocity等,使得开发者可以根据项目需求选择最适合的模板语言。Action结果类型也是多样化的,可以返回字符串、Stream、甚至重定向或转发到其他页面。 ...

    狂神说springmvc笔记.zip

    如Velocity或Freemarker作为模板引擎,可以生成动态HTML内容,实现前后端分离。 在"狂神说springmvc笔记.zip"中,读者可以通过深入学习这些知识点,掌握SpringMVC的使用技巧和最佳实践,提升自己的Java Web开发...

    struts2 学习重点笔记

    - **视图**:负责向用户展示界面,通常使用 JSP 或模板技术如 FreeMarker 和 Velocity。 - **控制器**:处理用户的请求,协调模型和视图,使用 Servlet、Action 实现。 **1.3 Struts2 的特性** - **单点控制**:...

    大数据导论学习记录笔记

    * 大数据的5个特点:volume(规模大)、variety(类型多)、velocity(速度快)、value(有价值)、veracity(真实性) 大数据技术属性 * 云计算:一种无处不在的、便捷的且按需的对一个共享的可配置的计算资源...

    webworkwebwork笔记

    从给定的文件信息来看,这里涉及到的是WebWork框架的学习笔记与配置,以及如何将WebWork与Spring、Hibernate集成在一起的示例。下面,我们将详细地解析这些知识点: ### WebWork框架简介 WebWork是一个开源的Java ...

    狂神说Redis笔记.pdf

    在大数据时代,Nosql通常需要应对3V问题(Volume、Variety、Velocity)以及3高的要求(High concurrency、High availability、High performance),因此Nosql数据库在设计时会特别考虑这些问题。 狂神的Redis笔记不...

    bigdata笔记1

    "bigdata笔记1"可能包含的是对大数据基础知识、主要技术框架及其应用的概述。以下是一些可能涵盖的重要知识点: 1. **大数据定义**:大数据不仅仅是数据的量大,它还包括数据的多样性、速度和价值。大数据的4V特性...

    大数据技术原理学习笔记.docx

    本笔记基于林子雨老师在MOOC上的《大数据技术原理》课程,旨在为IT从业者和大学生提供一个全面了解大数据的基础框架。 首先,我们要认识到大数据的发展背景。随着互联网的普及,以及物联网、社交媒体、移动设备等...

    struts2综合笔记

    - 支持多种视图技术,如 JSP、FreeMarker、Velocity 等。 - 基于 Spring AOP 思想的拦截器机制,易于扩展和定制。 - 强大的输入校验功能。 **历史背景**: - **Struts1 vs. Struts2**: - **共同点**: 都遵循 MVC...

Global site tag (gtag.js) - Google Analytics