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