Dynamic Grails Url Mapping config

后端 未结 4 1681
醉酒成梦
醉酒成梦 2020-12-15 10:13

How can I dynamically build a list of mappings - instead of:

class UrlMappings {
static mappings = {
   \"/helpdesk/user/$action?/$id?\" (controller=\"helpde         


        
4条回答
  •  忘掉有多难
    2020-12-15 11:15

    The grailsUrlMappingsHolder bean is available in services and controllers. Although it's concrete implementation of UrlMappingsHolder doesn't have an add method, its superclass does. Simple as this in grails 2.3.4

    def grailsUrlMappingsHolder
    
    def addMapping() {        
        grailsUrlMappingsHolder.addMappings({
            "/admin"(controller:"admin" action:"index")  
        });        
    }
    

提交回复
热议问题