8.4.8 Mapping Wildcards - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.1.9
8.4.8 Mapping Wildcards
Grails' URL mappings mechanism also supports wildcard mappings. For example consider the following mapping:static mappings = { "/images/*.jpg"(controller: "image") }
/image/logo.jpg. Of course you can achieve the same effect with a variable:static mappings = { "/images/$name.jpg"(controller: "image") }
static mappings = { "/images/**.jpg"(controller: "image") }
/image/logo.jpg as well as /image/other/logo.jpg. Even better you can use a double wildcard variable:static mappings = { // will match /image/logo.jpg and /image/other/logo.jpg "/images/$name**.jpg"(controller: "image") }
name parameter obtainable from the params object:def name = params.name println name // prints "logo" or "other/logo"
excludes setting inside the UrlMappings.groovy class:class UrlMappings {
static excludes = ["/images/*", "/css/*"]
static mappings = {
…
}
}/images or /css.
