简体   繁体   中英

Get all methods from controller in grails 3

在这个问题显示从grails 2中的控制器获取所有方法2.如何获得grails 3?

It's a bit easier in Grails 3 (and Grails 2 if you only use methods for actions and no closures):

import grails.web.Action

def data = grailsApplication.controllerClasses.collect { controller ->
   [controller: controller.logicalPropertyName,
    controllerName: controller.fullName,
    actions: controller.clazz.methods.findAll { it.getAnnotation(Action) }*.name.sort()]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM