API / Apache Grails Interview questions
What is a Grails controller?
A controller is a Groovy class in grails-app/controllers whose public methods (or closures, in older style) automatically become request-handling actions, mapped to URLs by convention without any explicit routing code required for the common case.
A class named BookController with an action method show() is, by default, reachable at /book/show, with Grails handling parameter binding, redirecting, and rendering views (or JSON, for REST-style controllers) based on what the action returns or explicitly calls, like render or redirect. Controllers typically stay thin, delegating actual business logic to services, and pull query parameters or form data through the implicit params object rather than parsing the raw request manually.
Because the URL-to-action mapping follows a predictable naming convention, a developer reading a controller class can usually infer its reachable URLs without consulting a separate routing configuration file, though custom URL patterns can still be defined explicitly when the default convention doesn't fit.
More Related questions...