我无法使用Revel检索表单数据。不过,我可以检索查询参数。
我有这个控制器来测试c.Params的内容
func (c UserController) SaveUser() revel.Result {
return c.RenderJson(c.Params) //just for check the content
}当我传递一个查询param (testkey,value)时,我得到:
{
"Values": {
"testkey": [
"value"
]
},
"Fixed": null,
"Route": null,
"Query": {
"testkey": [
"value"
]
},
"Form": null,
"Files": null
}一切都还好。但是当我传递一个表param时,我没有得到任何数据:
{
"Values": {},
"Fixed": null,
"Route": null,
"Query": {},
"Form": null,
"Files": null
}这是一个PUT请求,我正在使用邮递员传递数据。
谢谢。
发布于 2016-03-02 10:18:05
我找到了解决办法。我必须将表单参数作为方法参数传递:
// id and nickname are form params
func (c UserController) SaveUser(id, nickname string) revel.Result {
return c.RenderJson(c.Params)
}https://stackoverflow.com/questions/35685902
复制相似问题