审核中~
溜忙之道
首页
溜忙手册
offer之道
项目Git
写文章
登录
·
注册
登录
没有账号,去注册
注册
已有账号,去登录
博客
gin 获取post的中所有参数
南易_站长
阅读量:9562
关注
gin 获取post的中所有参数
# [gin 获取post的中所有参数](https://www.cnblogs.com/lkl6/p/13935526.html) 此方式只能获取post默认方式application/x-www-form-urlencoded的参数 ``` ctx.Request.ParseForm() for k, v := range ctx.Request.PostForm { fmt.Printf("k:%v\n", k) fmt.Printf("v:%v\n", v) } ``` 此方式能获取post中form-data和x-www-form-urlencoded两种方式 ``` c.Request.ParseMultipartForm(128)//保存表单缓存的内存大小128M data := c.Request.Form fmt.Println(data) ``` formCache表单缓存其实也是一个url.Values,通过调用http.Request的ParseMultipartForm对提交的表单解析,获得里面的数据保存在http.Request的PostForm字段中,最后从req.PostForm获取表单数据,赋值给c.formCache表单缓存即可。
评论
表情
发送
0
评论