Created
January 18, 2014 21:03
-
-
Save athlan/8496417 to your computer and use it in GitHub Desktop.
GET and POST params from HttpServletRequest in Grails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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