API / Apache Grails Interview questions
How does Grails apply convention-over-configuration to map URLs to controllers?
By default, Grails derives a controller's base URL directly from its class name (stripped of the "Controller" suffix and lower-cased), and each public action method within it becomes a further path segment — no routing table has to be written for the common case to work.
A class named ProductController is reachable at /product, and its list() action responds at /product/list; if no action is specified in the URL, an index() action (if defined) handles the request by default. Grails also derives the matching GSP view path the same way — /product/list looks for grails-app/views/product/list.gsp automatically, without the action needing to explicitly specify which view to render.
When this convention doesn't fit — a cleaner public-facing URL, a RESTful resource path, or a URL that needs to embed a parameter directly in its path — Grails supports explicit URL mappings defined in UrlMappings.groovy, which override the default convention for whatever specific patterns are declared there while leaving the rest of the application's controllers to keep using the default behavior.
More Related questions...