如何使用GO&#x27的NET/HTTP检查是否以帖子表格中存在值?
根据文档:
PostFormValue返回帖子,补丁或PUT请求主体的命名组件的第一个值。 URL查询参数被忽略。 如有必要 并忽略这些功能返回的任何错误。 如果不存在键,则postformvalue返回空字符串。
因此,函数request.postformvalue(键字符串)字符串
当键>键
时返回一个空字符串在邮局中不存在,而是存在于其存在且价值为空的时。
我只能检查钥匙是否在邮局中,无论其价值如何?
According to the documentation:
PostFormValue returns the first value for the named component of the POST, PATCH, or PUT request body.
URL query parameters are ignored.
PostFormValue calls ParseMultipartForm and ParseForm if necessary
and ignores any errors returned by these functions.
If key is not present, PostFormValue returns the empty string.
So the function Request.PostFormValue(key string) string
returns an empty string when key
does not exist in the POST body, but also when it exists and its value is empty.
How can I only check if the key is in the POST body, regardless of its value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解析表单,然后检查是否键是在发布表单。
Parse the form and then check to see if the key is set in the post form.