我正在使用 grails 2.0.1 并覆盖渲染方法。
我有以下代码。
grailsApplication.controllerClasses.each { controller ->
//keep old render method
def original = controller.metaClass.getMetaMethod("render", [Map] as Class[])
controller.metaClass.originalRender = original.getClosure()
controller.metaClass.renderForBrand = { Map args ->
originalRender(args)
}
}
在 original.getClosure() 我得到以下错误。
Message: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.reflection.CachedMethod.getClosure() is applicable for argument types: () values: []
Possible solutions: getClass()
Line | Method
->> 300 | evaluateEnvironmentSpecificBlock in grails.util.Environment
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 293 | executeForEnvironment in ''
| 269 | executeForCurrentEnvironment . . in ''
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . . . . . . . . . . in ''
^ 662 | run in java.lang.Thread
在 grails 1.3.7 中,我的代码运行良好,在 grails 2.x 的情况下,它会失败。非常感谢任何帮助。谢谢。