Grails使用POST请求中的XML填充params [英] Grails populate params with XML from POST request

查看:220
本文介绍了Grails使用POST请求中的XML填充params的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RestFull grails API,我通过grails Controller公开。
我需要自动绑定在POST请求中发送的xml数据。
我不认为使用groovy bindData(object,params)作为 params 引用似乎不是具有XML元素。我在UrlMappings中使用 parseRequest = true ,但是 params Object没有xml元素。

I have a RestFull grails api that i expose through grails Controller. I need to automatically bind the xml data sent in a POST request. I don't think using groovy bindData(object,params) works as the params reference seems not having the xml elements. i use the parseRequest=true in the UrlMappings but yet the params Object does'nt have the xml elements.

我是否缺少一些其他配置,以便我的params对象自动填充xml body元素?

am i missing some other config so that my params object get automatically populated with the xml body elements?

推荐答案

看来正确的做法是使用:

it seems the right way to do it is to use:

request.reader.text

来获取原始xml。其他方法对我来说并不成功。

to get the raw xml. the other methods were not successfull for me.

这篇关于Grails使用POST请求中的XML填充params的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆