////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////


== params



=== Purpose


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


=== Examples


To obtain a request parameter called `id`:
[source,groovy]
----
class BookController {
    def show() {
        def book = Book.get(params.id)
    }
}
----

To perform data binding (see link:{guidePath}theWebLayer.html#dataBinding[data binding] in the user guide):

[source,groovy]
----
def save() {
    def book = new Book(params) // bind request parameters onto properties of book
}
----


=== Description


The standard Servlet API provides access to parameters with the `HttpServletRequest` object. Although Grails provides the same capability through the link:{controllersRefFromRef}request.html[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 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 link:{domainClassesRefFromRef}properties.html[properties] property:

[source,groovy]
----
def book = new Book(params)
book = Book.get(1)
book.properties = params
----

For further reading see link:{guidePath}theWebLayer.html#dataBinding[data binding] in the user guide.
