(Quick Reference)

namespace

Purpose

The namespace property is optional and defines a namespace for a controller. Multiple controllers may be defined in the same namespace. Multiple controllers may be defined with the same name as long as they are defined in separate packages and are not defined in the same namespace.

When URL generation targets a controller and no namespace is specified, Grails resolves the namespace from the target controller. If exactly one controller has that name, controller and action are enough to generate the correct namespaced or non-namespaced URL. Specify namespace only when more than one controller shares the same name, or when you need to choose a namespace explicitly.

Examples

grails-app/controllers/com/app/reporting/PrintingController.groovy
package com.app.reporting

class PrintingController {

    static namespace = 'reports'

    // ...
}
grails-app/controllers/com/app/reporting/AdminController.groovy
package com.app.reporting

class AdminController {

    static namespace = 'reports'

    // ...
}
grails-app/controllers/com/app/security/AdminController.groovy
package com.app.security

class AdminController {

    static namespace = 'users'

    // ...
}

See the namespaced controllers docs for more information.