Skip to content

Instantly share code, notes, and snippets.

@athlan
Created January 18, 2014 21:03
Show Gist options
  • Save athlan/8496417 to your computer and use it in GitHub Desktop.
Save athlan/8496417 to your computer and use it in GitHub Desktop.
GET and POST params from HttpServletRequest in Grails
package com.selly.filters
import org.codehaus.groovy.grails.web.util.WebUtils
class ParamsFilters {
List globalParams = [
"controller",
"action",
"format"
]
def filters = {
all(controller:'*', action:'*') {
before = {
Map paramsRequest = params.findAll {
return !globalParams.contains(it.key)
}
Map paramsGet = WebUtils.fromQueryString(request.getQueryString() ?: "")
Map paramsPost = paramsRequest.minus(paramsGet)
request.setAttribute('paramsGet', paramsGet)
request.setAttribute('paramsPost', paramsPost)
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment