"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Tag Libraries/params.html" (14 Sep 2022, 60658 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)



A mutable multi-dimensional map (hash) of request (CGI) parameters.


To obtain a request parameter called id:

class BookController {
    def show() {
        def book = Book.get(params.id)

To perform data binding (see data binding in the user guide):

def save() {
    def book = new Book(params) // bind request parameters onto properties of book


The standard Servlet API provides access to parameters with the HttpServletRequest object. Although Grails provides the same capability through the request object, it goes a bit further by providing a mutable map of request parameters called params.

The params object can be indexed into using the array index operator or de-reference operator, so given so given the URL /hello?foo=bar you can access foo with

println params.foo

The params object can also be used to bind request parameters onto the properties of a domain class using either the constructor or the properties property:

def book = new Book(params)
book = Book.get(1)
book.properties = params

For further reading see data binding in the user guide.