contentType := c.Request.Header.Get("Content-Type")
fmt.Println("++contentType++",contentType)
id,_:=c.GetPostFormMap("id")
name,_:=c.GetPostFormMap("name")
fmt.Println("GetPostFormMap++",id,name)
name2,_:=c.GetPostForm("name")
fmt.Println("++GetPostForm++",name2)
fmt.Println("++c.Request.PostForm++",c.Request.PostForm)
nameArr:=c.PostFormArray("name")
fmt.Println("PostFormArray++",nameArr,reflect.TypeOf(nameArr))
formData,err:=c.MultipartForm()
fmt.Println("++MultipartForm++",formData,err)
/**
++contentType++ application/x-www-form-urlencoded
GetPostFormMap++ map[1:1 2:2] map[]
++GetPostForm++ womende
++c.Request.PostForm++ map[id[1]:[1] id[2]:[2] name:[womende nimende]]
PostFormArray++ [womende nimende] []string
++MultipartForm++ <nil> request Content-Type isn't multipart/form-data
*/

本文详细介绍使用GoLang处理HTTP请求中的表单数据,包括读取Content-Type、使用GetPostFormMap、GetPostForm、PostFormArray方法获取数据,以及处理multipart/form-data类型的文件上传。
470

被折叠的 条评论
为什么被折叠?



