API / Apache Grails Interview questions
Explain the internal working of Grails' convention-based URL mapping?
Grails resolves an incoming URL against a prioritized set of mapping sources, checking explicit application-defined patterns before falling back to the generic controller/action convention, so both approaches can coexist in the same application.
Explicit patterns declared in UrlMappings.groovy are checked first, since they represent an intentional override of the default behavior; a URL segment like /products/$id in such a mapping automatically extracts id into the request's params map. If no explicit pattern matches, Grails falls back to parsing the path directly as /controller/action/id, looking for a controller class and action method whose names match those segments, ultimately falling back to an index action if no specific action segment was given at all.
This two-tier resolution — explicit mappings first, convention-based fallback second — is what lets an application define a handful of clean, custom URLs for its most important routes while every other controller keeps working automatically under the default convention without needing its own explicit mapping entry.
More Related questions...