知识点是Groovy中的模板引擎

GStringTemplateEngine

第一个例子:

  

def binding = [
firstname : "Grace",
lastname : "Hopper",
accepted : true,
title : 'Groovy for COBOL programmers'
]
def engine = new groovy.text.GStringTemplateEngine()
def text = '''\
Dear <%= firstname %> $lastname, We <% if (accepted) print 'are pleased' else print 'regret' %> \
to inform you that your paper entitled
'$title' was ${ accepted ? 'accepted' : 'rejected' }. The conference committee.
'''
def template = engine.createTemplate(text).make(binding)
println template.toString()

第二个例子:

String stringFromDatabase = 'Hello ${name}!'
String name = 'world' def engine = new groovy.text.SimpleTemplateEngine()
assert 'Hello world!'== engine.createTemplate(stringFromDatabase).make([name:name]).toString()

最新文章

  1. 转:隐马尔可夫模型(HMM)攻略
  2. mybatis入门基础(二)----原始dao的开发和mapper代理开发
  3. Script 简单语句的练习题
  4. [2015hdu多校联赛补题]hdu5372 Segment Game
  5. TYVJ P1026 犁田机器人 Label:水
  6. c语言typedef的用法-解惑阿!很多天书般的东西解释的不错(转)
  7. EASYUI Dialog的基本使用
  8. http_build_query函数(学习)
  9. Entity Framework系列文章导航
  10. linux下服务器管理
  11. POJ Octal Fractions(JAVA水过)
  12. 深入理解Java虚拟机到底是什么
  13. [SHOI2014]三叉神经树
  14. OpenResty的现状、趋势、使用及学习方法
  15. centos7下kubernetes(10。kubernetes-daemonset)
  16. mybatis理解(0)
  17. dev16 cxgrid 在DLL里报0地址错
  18. linux 测试网络延迟
  19. JedisCluster中应用的Apache Commons Pool对象池技术
  20. spring jdbc批量插入

热门文章

  1. rpm小结
  2. 2016级算法期末上机-D.简单&#183;AlvinZH&#39;s Fight with DDLs I
  3. 开源单点登录系统CAS入门
  4. windows 虚拟机VMware 安装linux系统注意事项!!!
  5. Go语言目录
  6. HTML常用汇总
  7. iterm自动登录ssh脚本
  8. (转载)IDEA新建项目时,没有Spring Initializr选项
  9. (java/javascript) list 交集 并集 差集 去重复并集
  10. java调用svnkit工具类上传本地文件到svn服务器