jjzjj

PostFormValue

全部标签

c - 在 golang 中错误地解析带有标点符号的帖子数据

我知道如何在golang中解析post数据r.ParseForm()pid:=r.PostFormValue("pid")code:=r.PostFormValue("code")lang:=r.PostFormValue("lang")author:=r.PostFormValue("author")但是post数据是pid=1&code=#include\x0Aintmain()\x0A{\x0A\x09printf(\x223\x5Cn\x22);\x0A\x09return0;\x0A}&lang=c&author=11(这是从nginx的日志中获取的)所以当我解析数据时,它可

go - 什么时候应该使用 ParseForm,什么时候应该使用 FormValue 和 PostFormValue?

我只是想获取表单数据,但我不太了解该使用哪种方法。在本文中:http://astaxie.gitbooks.io/build-web-application-with-golang/content/en/04.1.html他们使用r.ParseForm()并通过执行r.Form["username"]获取发布值。但是当我在自己的代码中尝试这样做时它不起作用,我反而得到了一段字符串,所以我不得不做r.Form["username"][0]来获得字符串值。为什么这与文章中显示的不同?为什么我会得到一段字符串?还有另一种方法可以像这样使用r.FormValue("username")。然后是