Search code examples
grails

Grails Urlmapping 404 for group


I organized my url mappings in grails with groups.

Example from UrlMappings:

class UrlMappings {

static mappings = {
    group "/rest", {
        "/" {
            controller = "rest"
            action = "index"
        }
        "/method1" {
            controller = "rest"
            action = "method1"
        }           
    }
    "/webservice/" {
        controller = "webservice"
        action = "index"
    }
}

What I want: When the Url is called /rest/notexists, I want a 404 for this path. But only for /rest group, so the 404 should belong to the group rest. Other 404 are handled by my backbone router.

Any ideas?


Solution

  • I solved it with a catch all at the end of the rest group:

     "/**" {
                controller = "rest"
                action ="notFound"
     }