天天看点

grails动态调用方法

见例子:就在这一行:operationImplService."${processAction}"(params1,params2)

def operationImplService
    def test() {
        def processAction = "dm"
        def postResult = operationImplService."${processAction}"('abc')
        println "postResult:"+postResult
    }
}
class OperationImplService {
    def dm(String param) {
        println "调用我了,参数:${param}"
        return true
    }
}      
def arg = [1,2]
def tools = new Tools()
println tools."max"(*arg)