6
Groovy中允许做一些字符串的好东西在前端页面,例如:Groovy的扩展String类
${"hello".capitalize()}
我如何添加一个新的自定义方法将String
类?像:
${"hello".custom()}
Groovy中允许做一些字符串的好东西在前端页面,例如:Groovy的扩展String类
${"hello".capitalize()}
我如何添加一个新的自定义方法将String
类?像:
${"hello".custom()}
使用的metaClass
String.metaClass.custom = { //dosomething }
见http://www.groovyexamples.org/2010/07/19/dynamically-add-properties-to-a-class/