# params

## Purpose

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

## Examples

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
    }

## Description

The standard Servlet API provides access to parameters via 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 via de-refrencing so given the URL `/hello?foo=bar` you can obtain the value of foo as follows:

    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.