据我所知,如果我想在 Controller 中创建一个 Action ,那么我可以通过以下方式完成:
class My Controller {
def myAction = {
println "in my action "
}
}
或者我可以通过以下方式创建它:
class My Controller {
def myAction(){
println "in my action "
}
}
有人可以告诉我这两种方法之间的区别,或者我的概念或看法有什么问题吗?
请您参考如下方法:
第一个实现是在 Controller 中定义公共(public)闭包,第二个是使用公共(public)方法。
第二种方式是在 grails 2 中引入的,被广泛认为是最好的方式。
我能想到的几个原因:
更新:
Why should grails actions be declared as methods instead of closures and what difference does it make?




