views:

340

answers:

1

How do I create a catch-all URL-mapping in Grails?

The following Grails UrlMapping ..

class UrlMappings {
  static mappings = {
    "/$something"{
      controller = "something"
      action = "something"
    }
  }
}

.. appears to match ^/[^/]* but how do I create an UrlMapping matching all URLs (^/.*)?

+4  A: 

You're looking for the ** "double wildcard". Example:

   class UrlMappings {
      static mappings = {
        "/**"(controller: "something", action: "something")
      }
    }
ataylor
Excellent! One remaining question - how do I obtain the matched string - that is the value of /**?
knorv
Found the answer: "/$something**" gives me params.something - thanks!
knorv