Grails 2.4.4。 grails.rest.RestfulController。如何覆盖删除方法?

时间:2015-03-02 20:43:05

标签: grails grails-controller

如何覆盖删除方法?

这种结构不会覆盖我做错的方法吗? :

def NOT_TOUCH = ['Assets', 'Dbdoc', 'Login', 'Logout']

grailsApplication.controllerClasses.each {controller ->

            if(NOT_TOUCH.findAll{it == controller.name} == []){

                controller.metaClass.delete = { Map m ->

                     ....
                }
            }
        }

1 个答案:

答案 0 :(得分:-1)

仅适用于重定向和回复:

def NOT_TOUCH = ['Assets', 'Dbdoc', 'Login', 'Logout']

        grailsApplication.controllerClasses.each {controller ->

            if(!(controller.name in NOT_TOUCH)){

                controller.clazz.metaClass.invokeMethod = { String name, args ->

                    ...
                }
            }
        }