Velocity手册-中文版
Velocity 模板使用指南》中文版

2.Escaping Valid VTL References(封装有效的引用)如下示,如果没有#set( $email = "foo" )这一行且java代码中Context对象中没有放放email对象,将直接输出$email.#set( $email = "foo" )$email如果email己定义了 (比如它的值是foo),而这里你却想输出$email. 这样一个字符串,就需要使用转义字符”\”.## The following line defines $email in this template:#set( $email = "foo" )$email\$email\\$email\\\$email上面的模板在web页面上的输出将是:foo$email\foo\$email但如果email并没有定义,我们这样写:.$email\$email\\$email\\\$email输出就原封不动了:$email\$email\\$email\\\$email注意:当己定义变量和未定义变量一起输出时,会输出字面意思,如下便,$moon是未定义的:#set( $foo = "gibbous" )$moon = $foo输出到web页面中将是$moon = gibbou11.Case Substitution(可选的格式)至此,你对velocity的refenerce己比较熟悉了, 你可以在你的模板中开始应用这些功能. 但你还可以知道的是Velocity references从java语法中汲取了一些优点以便模板设计者更容易使用VTL.比如:$foo$foo.getBar()## 等同于$foo.Bar$data.setUser("jon")##等同于#set( $er = "jon" )$data.getRequest().getServerName()##等同于$data.Request.ServerName## is the same as${data.Request.ServerName}这里示例了你可选的一些引用方式. VTL汲取了java语法和java bean的一些简洁语法以解析java代码中Context中的对象和这些对象的命令及属性---这样,一个java对象的所有功能都可以展示到视图中了.Velocity也借见了java Bean的规范(Bean specifications defined by Sun Microsystems), 是大小写敏感的; 但Velocity会尽可能的帮你修正错误. 当命令getFoo()通过指令 $bar.foo在模板中引用时,Velocity的搜索规则我们在前面己讲了,你还记得是什么吗?.注意:模板中引用的必须是通过java Bean中的getter/setter 实现的,而直接的java对象的数据域是不能直接引用的,如$ 会解析到 class Foo's getName() 的实例方法,但不会解析到Foos类的public Name 这个实例变量.12.Directives(指令符号)模板设计者使用“引用“生成动态内容, 指令(directives)–简单的说就是设计者在模板中操作java 对象—让视图设计者全面控制输出内容的格式.指令总是以 #开头后面紧跟具体的指令符. 就像引用一样(指令的一种),可以将指令理解为”表示这里是一个什么东东).如下例生成一个出错提示:#if($a==1)true enough#elseno way!#end这个例子中应使用括号将else分开.#if($a==1)true enough#{else}no way!#end1.#set指令#set用来给一个引用赋值.值可以被赋给变量引用或属性引用, 但要将它们放入括号中,如下示:#set( $primate = "monkey" )#set( $customer.Behavior = $primate )“左操作数被赋值“是引用操作的一个规则.=号右侧可能是以下类型之一:∙Variable reference变量引用∙String literal字符串∙Property reference 属性引用∙Method reference 命令引用∙Number literal 数字∙ArrayList 数组∙Map 映射下面是对上述类型设置的示例:#set( $monkey = $bill ) ## variable reference#set( $monkey.Friend = "monica" ) ## string literal#set( $monkey.Blame = $whitehouse.Leak ) ## property reference#set( $monkey.Plan = $spindoctor.weave($web) ) ## method reference#set( $monkey.Number = 123 ) ##number literal#set( $monkey.Say = ["Not", $my, "fault"] ) ## ArrayList#set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"}) ## Map注意: 在ArrayList类型引用的例子中,其原素定义在数组 [..]中, 因此,你可以使表$monkey.Say.get(0)访问第一个元素.类似的,引用Map 的例子中, 原素定义在 { } 中,其键和值间以:隔成一对,使用$monkey.Map.get("bannana") 在上例中将返回 'good', ( $monkey.Map.banana也会有同样效果).下面是一般的计算表达式:#set( $value = $foo + 1 )#set( $value = $bar - 1 )#set( $value = $foo * $bar )#set( $value = $foo / $bar )但注意:如果右边的操作数是一个属性或命令的引用而返回null,那么赋值将不会成功,且在随后的VTL 中也不能再取出使用. 如下例:#set( $result = $query.criteria("name") )The result of the first query is $result#set( $result = $query.criteria("address") )The result of the second query is $result如果$query.criteria("name")返回的是字符串 "bill", 但$query.criteria("address")返回null, 上面的TVL输出结果将是:The result of the first query is billThe result of the second query is bill这对与初学者的理解有些麻烦,比如在#foreach loops中,你使用#set给一个属性或命令赋值时,如下例示:#set( $criteria = ["name", "address"] )#foreach( $criterion in $criteria )#set( $result = $query.criteria($criterion) )#if( $result )Query was successful#end#end在上例中,就不能依赖if( $result )来决定查询是否成功. $result一但被#set 为null (context会同样), 它将不能被赋其它值 (不能从 context中取出).一个解决办法是,每次都将$result设为false. 如果$query.criteria()调用成功,就可以检测到. #set( $criteria = ["name", "address"] )#foreach( $criterion in $criteria )#set( $result = false )#set( $result = $query.criteria($criterion) )#if( $result )Query was successful#end#end注意:#set不需要使用#end来声明结尾.2.Literals (语义解析)使用#set指令时,变量如果用“”引起会被解析,如:#set( $directoryRoot = "www" )#set( $templateName = "index.vm" )#set( $template = "$directoryRoot/$templateName" )$template输出的将是:www/index.vm但当用单引号引起来时,就不会被解析::#set( $foo = "bar" )$foo#set( $blargh = '$foo' )$blargh输出后会是:bar$foo默认情况下,不会解析单引号中的变量,当然,这可以通过改变Velocity的配置参数来改变:velocity.properties such that stringliterals.interpolate=false.另外, 指令#literal元素可以用来输出字面意思,如下示.#literal()#foreach ($woogie in $boogie)nothing will happen to $woogie#end#end会输出::#foreach ($woogie in $boogie)nothing will happen to $woogie#end3.Conditionals(条件判断)1.If / ElseIf / Else#if指令用来根据条件在页面中输出内容, 如下简单的例子:#if( $foo )<strong>Velocity!</strong>#end根据变量$foo计算后是否为true决定输出, 这会有两种情况: (i) $foo的是值是一个boolean (true/false)型并有一个true value, 或(ii) 它是一个非null值. 要记者,Velocity context 中只能包含Objects, 因此当我们讲'boolean'时, 它就是一个Boolean (the class).在#if和#end的内容是否会输出,由$foo是否为true决定. 这里,如果$foo is true, 输出将是: "Velocity!". 如果$foo为null或false,将不会有任何输出.#elseif或#else可以#if和组合使用. 如果第一个表达式为true,将会不计算以后的流程,如下例假设t $foo是15 and $bar产6.#if( $foo < 10 )<strong>Go North</strong>#elseif( $foo == 10 )<strong>Go East</strong>#elseif( $bar == 6 )<strong>Go South</strong>#else<strong>Go West</strong>#end输出将会是Go South.2.Relational and Logical Operators(关系和逻辑运算)Velocity使用==来做比较,如下例.#set ($foo = "deoxyribonucleic acid")#set ($bar = "ribonucleic acid")#if ($foo == $bar)In this case it's clear they aren't equivalent. So...#elseThey are not equivalent and this will be the output.#end注意:==计算与java中的==计算有些不同:不能用来测试对象是否相等(指向同一块内存). Velocity 中是否相等仅直接的用来比较numbers, strings的值, or objects的toString()结果是否相等. 如果是不同的对象,会调用它们的toString()命令结果来比较.Velocity也使用AND, OR and NOT 执行逻辑运算.详细说明请参看《VTL参考中文版》,如下是一些简单示例:## logical AND#if( $foo && $bar )<strong> This AND that</strong>#end仅当$foo$bar和都为true时,#if()才会输出中间内容.OR 运算例子## logical OR#if( $foo || $bar )<strong>This OR That</strong>#end$foo或$bar只要有一个为true就可以输出。
《Velocity java开发指南》中文版

《Velocity java开发指南》中文版本文档来自网络,本人将其收集整理了一下,主要调整了一下格式.如有出入,请参照网络原版,原版地址记不清了!O(∩_∩)O哈哈~目录开始入门 (3)参考资源: (4)它是如何工作的? (5)单实例还是多实例(To Singleton Or Not To Singleton...)? . (7)The Context (9)Using Velocity In Servlets (12)Using Velocity In General Applications (15)Application Attributes (19)EventCartridge and Event Handlers(事件分发和处理) (20)Velocity Configuration Keys and Values(配置参数名字和值说明) (23)Configuring the Log System(日志记录配置) (26)Configuring Resource Loaders(资源装载器配置) (29)Template Encoding for Internationalization(字符编码和国际化) (32)Velocity and XML (33)FAQ (Frequently Asked Questions)开发中常见的问题解答. (36)Summary (37)Appendix 1 : Deploying the Example Servlet (38)开始入门Velocity是一基于java语言的模板引擎,使用这个简单、功能强大的开发工具,可以很容易的将数据对象灵活的与格式化文档组装到一起;希望本文能指引使用velocity在开发基于servlet或一般java应用程序的应用上快速起步。
1.Getting Started取得Velocity并在你的机器上开始运行很容易,以下是全部详细的说明:取得Velocity发布版本,go here。
velocity中文手册

Velocity用户指南什么是Velocity?Velocity是基于Java的模板引擎。
它允许Web页面开发者引用Java代码中定义的方法。
Web设计者可以和Java程序开发者并行开发遵循MVC模式的Web 站点。
这意味着,Web设计者可以将精力放在好的Web站点设计上,而Java 程序开发者可以将精力放在编写代码上。
Velocity将Java代码从Web页面中分离,使Web站点更具长期可维护性,并提供了一种替代JSP或PHP的方案。
VTL(Velocity Template Language)介绍VTL提供一种简单、容易和干静的方法将动态内容合并到Web页面。
VTL使用引用(references)将动态内容插入到Web页面中。
变量是一种引用,可以指向Java代码中的定义内容,或者由Web页面中的VTL语句来获得值。
下面是一个可以插入到HTML文档的VTL语句的例子:#set( $a = "Velocity" )VTL语句以#开头,并包含指令(set)。
变量以$开头,用引号引起。
引号可以是单引号,也可以是双引号。
前者引用具体的String值;后者可以包含Velocity 引用,例如”hello, $name”,$name会用其当前的值替换。
上面的例子是将值Velocity赋值给变量a。
当变量被赋值后,就可以在HTML文档的任何地方引用,下面是Hello Velocity World!的例子:<html><body>#set( $foo = "Velocity" )Hello $foo World!</body><html>注释VTL支持单行注释(以##开始)和多行注释(包括在#*和*#之间),下面是一个例子:This text is visible. ## This text is not visible.This text is visible.This text is visible. #* This text, as part of a multi-line comment,is not visible. This text is not visible; it is also part of themulti-line comment. This text still not visible. *# This text is outsidethe comment, so it is visible.## This text is not visible.引用VTL有3种类型的引用:变量、属性和方法。
Velocity软件使用说明bak

Velocity汉化步骤首先确认Velocity2.0门禁系统软件已经安装完毕。
1、将Customs.cst文件复制到C:\Programs Files\Hirschelectronics\Velocity目录下。
2、点击“开始”\“程序”\Hirsch Electronics Velocity\Velocity键,进入软件中。
3、点击Files\Import\Export\Customsation进入汉化文件导入界面,点击“Next”后选择“Import”进行汉化。
4、第3步完成后,点击“Console”目录下的最后一项“参数选择”,将“概要”中第2项打上“√”。
5、第4步完成后,在计算机屏幕右下角用右键点击“Services”\Setting,同样将“Database”中第2项打上“√”。
6、以上步骤完成后,退出软件,重新启动计算机进入Velocity软件。
软件使用说明1、首先确认系统硬件已经和计算机连接完毕(计算机通过Com口与控制器通讯)。
设置端口2、打开Velocity软件,在配置\DIGI*TRAC配置\SNET点击增加新SNET端口,在名称处给该端口一个新名称(一般设为Com1),然后在端口配置中选择波特率(一般选9600)和端口,然后点确认键完成该端口的添加。
添加控制器3、端口增加完毕后,点击该端口并继续点击增加新控制器,在新控制器属性界面内名称处给控制器设定一个新名称;在地址处给该控制器设定地址(控制器内的地址拨码开关是几则在该处就设定几);在型号处给该控制器设定型号(根据添加该控制器的具体型号而定,如2门控制器为M2、8门控制器为M8);在控制器时区处选择中国,其余均为默认值,点击确认键完成该控制器的添加。
门属性设置4、以8门控制器为例:控制器添加完毕后,点击该控制器并继续点击门,出现了Door1~Door8,双击Door1,在Door1的属性界面内点击报警输入,在设置界面内的报警模块处选择模块类型(一般默认值为DTLM2\MELM2),将出门按钮选中,选择触发继电器并屏蔽报警;其余均为默认值,点击确认键完成该Door1的设置。
velocity入门教程

</servlet> <servlet-mapping>
<servlet-name>velocity</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping> </web-app>
velocityContext.put("txt", "hello, world!");
StringWriter stringWriter = new StringWriter(); template.merge(velocityContext, stringWriter);
System.out.println(stringWriter.toString()); } }
代码中首先初始化一个 velocity 引擎,并载入一个.vm 文件,vm 就是 velocity 模板文
件的标准后缀,初始化 velocity 上下文,将一个叫做“hello, world!”的字符串以一个名
为“txt”的键,加入 velocity 上下文中,然后输出最终结果。
4
hello.vm 的内容为$txt
response); }
}
代码中,我们仅仅是向 request 域中放入了一个叫做“txt”的属性,然后指定了 vm
视图的路径,和使用 JSP 视图做法是一样的。
在/WEB-INF/views 下,创建一个 test.vm,内容如下
《Velocity Web应用开发指南中文版》

《V elocity1.4使用指南中文版》中文版来源声明:转载请保留此页声明**************************************************************************此文档为蓝杰实训学员拓展实训之用.蓝杰实训不对译文中某些说法可能会对您的系统或开发造成损害负责.如对您有所帮助,我们不胜荣幸!*************************************************************************本文属中的Velocity中文系列,本系包含如下文章:《Velocity Java开发指南中文版》(Developer`s Guide)《Velocity模板使用指南中文版》(User`s Guide)《Velocity Web应用开发指南中文版》(Web Application Guide)《VTL语法参考指南中文版》(VTL Reference)《DB4O中文系列之起步篇》...更多资料请访问/下载.**************************************************************************译者:javaFoundMail:javafound@@*************************************************************************目录1.使用Velocity构建Web应用 (3)e a Framework (3)3.Web应用用例 (3)4.不要改变己输出对象的状态! (4)5.HTML/XML字符转义 (4)6.应用安全性 (5)7.日志文件 (5)8.布署指南 (5)1.使用Velocity构建Web应用Velocity常见的用途是生成web页面,通常用来替换JSP技术.使用它生成页面有以下优势:∙简洁–一般的web美工不需要懂程序语言的就可以设计动态业面.∙Web系统容易维护–MVC推荐的做法是在页面中不要存在其它的脚本语言出现..∙容易访问数据模型的命令和属性–页面设计者通过引用简单的就可访问context中的java数据对象.∙一致性–Velocity可用做其它的文本模板生成任务,如如发送email.本文讲解了将Velocity应用与web应用的一些基本方法.e a FrameworkVelocity的主要目标是通过模板生成格式文档.因此,Velocity自身不提供任何Web相关的功能.当你需要开发Web应用时,需要一个框架来接收HTTP请求和,处理用户认证,执行业务逻辑调用,最后生成应答内容返回给客户端。
Velocity Intel CPU 水晶块用户手册说明书

This product is intended for installation only by expert users. Pleaseconsult with a qualified technician for installation. Improper installation mayresult in damage to your equipment. EK Water Blocks assumes no liabilitywhatsoever, expressed or implied, for the use of these products, nor theirinstallation. The following instructions are subject to change withoutnotice. Please visit our website at for updates. Beforeinstallation of this product, please read important notice, disclosure, andwarranty conditions that are printed on the back of the box.Before you start using this product, please follow these basic guidelines:Please carefully read the manual before beginning the installationprocess.Please remove your graphics card from the computer to assure thesafest mounting process and prevent any possible damage to yourGPU and/or graphics card circuit board (PCB).The EK Fittings require only a small amount of force to screwthem firmly in place since the liquid seal is ensured by the rubberO-ring gaskets.The use of corrosion inhibiting coolants is always recommendedfor liquid cooling systems, and mandatory for nickel platedwater blocks!Do not use pure distilled water! For best results EK rrecommendsthe use of EK-CryoFuel coolants.Make sure to thoroughly bleed air out of your water block, or you willnot reach optimal performance.TABLE OF CONTENTGENERAL INFORMATION ON WATER BLOCK COMPATIBILITY 4 BOX CONTENTS 5 WATER BLOCK DIMENSIONS 6 TECHNICAL SPECIFICATIONS AND WATER BLOCK PARTS 7SUPPORT AND SERVICE 18 SOCIAL MEDIA 18GENERAL INFORMATION ON WATER BLOCK COMPATIBILITYThis CPU liquid cooling unit is pre-assembled for use with modern Inteldesktop socket type motherboards. By default (out of the box) this waterblock supports the following CPU sockets:- Intel LGA-1150/1151/1155/1156- Intel LGA-1200- Intel LGA-2011(-3)- Intel LGA-2066Washer (5 pcs)Spring (4 pcs)Standoff - LGA 115x / AMD (4 pcs)BOX CONTENTSStandoff - 20xx (4 pcs) EK-Velocity universal CPU water block with the Intel bracket (1 pc)Allen Key 2.5 mm (1 pc)Thumb Nut (4 pcs)EK-Loop Intel CPU Backplate M4 (1 pc)Additional Jet Plate – 0.8 mm (1 pc)Thermal grease (1 pc)Universal Mounting Mechanism – You may not need every screw from this package. EAN: 3831109813065WATER BLOCK DIMENSIONSTECHNICAL SPECIFICATIONS AND WATER BLOCK PARTSTechnical Specification:- Dimensions (L x H x W): 91 x 91 x 22 mm - D-RGB cable length: 500 mm - D-RGB LED count: 20- D-RGB connector standard 3-pin (+5V, Data, Blocked, Ground)- Dimensions (L x H x W): 91 x 91 x 22 mm- D-RGB cable length: 500 mm- D-RGB LED count: 1- D-RGB connector standard 3-pin (+5V, Data, Blocked, Ground)REPLACING THE JET PLATE PROCEDURESTEP 1Please reference the table below to determine the optimal insert andjet plate needed for your type of socket.J1d= 1 mm J2d= 0.8 mmSTEP 2Unscrew the four M4 screws in counter-clock-wise direction from the bottom of the water block using the enclosed 2.5 mm Allen key to release the assembly, which consists of the water block top and jet plate. Upon replacing the jet plate, please reassemble the water block as shown in STEP 1 and STEP 2. Pay special attention to the insert orientation relative to the copper base and the water block top.Screw the four screws back in firmly, but not forcefully.INSTALLING THE WATER BLOCKBACKPLATESTEP 1 – NEW BACKPLATEInstall the Intel backplate for LGA-115x/1200 socket to the back of your motherboard. Align the holes on the motherboard with the holes on the backplate.STEP 2 – NEW BACKPLATEInstall four (4) M3 thumb screws onto your motherboard. It is mandatory to put 0.7mm plastic washer underneath each of the M3 thumb screws. Tighten the screws to the metal backplate until you reach the end of the thread. Using tools (such as pliers) is not recommended.BACKPLATESTEP 1 – OLD BACKPLATEIf already installed, please remove the motherboard from your computer and place it on an even surface with front facing down. STEP 2 – OLD BACKPLATEPreparing backplate rubber gasketThe enclosed rubber gasket is an essential part of the backplate and mounting system and must be used every time you install this water block on your motherboards.CONNECTING THE RGB LED STRIP (Optional)STEP 4 – OLD BACKPLATEInstall four (4) M3 thumb screws onto your motherboard. It is mandatory to put 0.7mm plastic washer underneath each of the M3 thumb screws. Tighten the screws to the metal backplate until you reach the end of the thread. Using tools (such as pliers) is not recommended.SUPPORT AND SERVICEIn case you need assistance or wish to order spare parts or a new mounting mechanism, please contact:https:///customer-support/For spare parts orders, refer to the page with “TECH NICAL SPECIFICATIONS AND WATER BLOCK PARTS” where you can find the EAN number of each part you might need.Include the EAN number with quantity in your request. Mounting Mechanism EAN can be found under “BOX CONTENTS”Thermal pads are readily available in the EK shop SOCIAL MEDIAEKWaterBlocks@EKWaterBlocksekwaterblocksEKWBofficialekwaterblocks。
Velocity官方指南

Velocity官方指南-使用Velocity如果你使用的是VelocityViewServlet或者其他的web框架,你不会直接调用到Velocity。
但是,如果在非web的应用中或者自己编写的web框架时,你将会像上面说的基本流程一样直接调用到Velocity 引擎。
另外一个需要记住的重点是,必须在使用Velocity合并模版之前,初始化Velocity引擎。
Velocity辅助类Velocity中包含一个叫做Velocity( org.apache.velocity.app.Velocity )的应用工具类。
这个类的主要是提供一些初始化Velocity时必须的方法,以及简化Velocity使用的一些常规方法。
这个在工程的javadoc中有描述,可通过阅读javadoc来获取更详细的说明。
本篇文档只是教程;所以,如果需要了解完整的API信息,javadoc是你最好的选择。
Velocity运行时引擎是为在同一个jvm中的其他使用者提供资源获取,日志记录等其他服务的单个实例。
因此,运行时引擎只会初始化一次。
你可以尝试初始化多次,但是只有第一次是有效的,后面的初始化操作都会被忽略。
Velocity工具类提供了五个用来配置运行时引擎的方法。
这五个配置方法如下:∙setProperty( String key, Object o )设置属性键key对应属性值为o。
值通常为字符串,在特殊情况下也可以是逗号分隔的一串值(如”foo,bar,woogie”),当然也可以其他值。
∙Object getProperty( String key )获取属性键key对应的值。
需要注意的是返回值的类型,不仅仅只是字符串类型∙init()使用jar包中的默认properties文件中配置的属性初始化运行时引擎∙init(Properties p)使用类型为java.util.Properties参数出入的属性来初始化运行时引擎∙init( String filename )使用文件名为filename的properties文件中的属性值初始化运行时引擎需要注意的是,在上面的这五个方法中,默认的properties是基础的配置,额外的properties是用来替换默认配置中对应的属性。