I'm trying to read the body content of a Grails request and it's mapping the request to the params even though I've commented out the grails.mime.types. I've also tried setting grails.mime.types to and empty map and it's still mapping.
The body content is xml and when Grails maps it, the key ends up being "<?xml version". Unfortunately, the system sending the POST is setting the content-type to application/x-www-form-urlencoded. I don't have control over them changing it.
I'm running Grails 1.2.1.
I've also tried setting format="xml" in my UrlMappings and adding the form content type to the xml mime.types but that didn't help 开发者_如何学编程either. And when I try to access the request.reader, it's empty.
If you want to access the request.reader directly instead of having the XML unmarshalled to a domain object, then try turning off parseRequest
like this:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"(parseRequest:false){
constraints {
// apply constraints here
}
}
"/"(view:"/index")
"500"(view:'/error')
}
}
I got this solution from: http://margotskapacs.com/2013/04/request-automatic-parsing-in-grails/
Try enabling 'parseRequest' in your mapping.
From the docs: "Grails will not provide automatic XML or JSON marshaling for you unless you specify the parseRequest argument in the URL mapping".
精彩评论