Differences between action and methods in Grails controllers

后端 未结 3 1664
执笔经年
执笔经年 2021-01-27 04:00

As far as I know, if I want to create an action in a controller then I can do it by:

class My Controller {
    def myAction = {
      println \"in my action \"
          


        
3条回答
  •  青春惊慌失措
    2021-01-27 04:22

    I'm not sure, but I think that it used to be the first way was the only way to do it, and then it changed to allow the second way. I think that the second way is the preffered way, but I'm not sure.

    [Edit]

    Here is another stack overflow post further explaining it:

    Why should grails actions be declared as methods instead of closures and what difference does it make?

提交回复
热议问题