Generic url mapping in grails

I am trying to do this:

"/templates/$tml"{
        view: "/templates/$tml"
    }

and this:

"/templates/$tml"{
        view: "/templates/${tml}"
    }

and this:

"/templates/$tml"{
        view: "/templates/${params.tml}"
    }

But none of them work. I have many GSP files in the template folder, and I don’t want to map them one by one, instead I want some kind of common code to display them as a controller map.

Thanks for the help!

+4
source share
2 answers

Have you tried something like this?

In UrlMappings.groovy:

"/templates/$tml"(controller: "templates", action: "generateView")

In TemplatesController.groovy:

def generateView(String tml){
    render(view: tml)
}
+6
source

I'm not sure, but you can try something like this

"/templates/$tml"(view: "/templates/$tml")

Normal procedure

"/templates/$tml"{
    controller = "general"
    action = "generalAction"
    //pageName = "yourpage"
 }
0
source

All Articles