Grails POST Rest service problem
I have the following urlmappings:
"/loader/" {
action = [POST:"savep"]
controller = 'loader'
}
savep is:
def savep = {
params.each {
log.debug "p:" + it
}
The client is sending in the post data:
{"vars":"{\"E32\":\"0\",\"E33\":\"0\",\"E34 ... etc
But I can't read the data in the controller; all I get is:
2011-03-15 13:20:42,646 [http-8080-2] DEBUG Test.LoaderController - p:action={POST=savep}
2011-03-15 13:20:42,647 [http-8080-2] DEBUG Test.Lo开发者_开发知识库aderController - p:controller=loader
Any hints ? Thanks in advance.
You need to specify that the request needs to be parsed, so in your mapping you need something like this:
"/loader/" (controller: "loader", parseRequest: true){
action = [POST: "savep"]
}
You can find more information in the Grails documentation about how to map to HTTP methods and about Web Services and the usage of parseRequest. There is also this other article about Grails and REST that could be useful.
精彩评论