当前位置:网站首页>go基础之web获取参数
go基础之web获取参数
2022-08-09 11:55:00 【51CTO】
web获取参数一般有header字段,body字段,Form字段
1、先说获取header字段
这样r.Header获取到所有Header的参数,如果想获取到其中一项使用
这2个语句的区别是第一个返回一个字符串切片,第二个返回字符串形式。
2、获取body字段
3、Form字段
r.ParseForm()是先解析参数,这样r.Form才能获取到。比如有参数abc=111,
使用r.Form["abc"]获取参数,也可以使用r.PostForm。
Form和PostForm之间的区别在于Form可以获取到URL后面的参数和post里面的参数,
PostForm只能获取post中的参数,也就是说Form是可以获取到get方法参数。
这2中方式可以不用执行r.ParseForm()就可以获取参数。
4、MultipartForm
从multipart编码的表单里面取出多少字节的数据。MultipartForm只能包含表单键值对而不包含URL键值对。
获取上传文件2中方式
1、r.ParseMultipartForm(1024)
2、r.FormFile("file")
边栏推荐
- [Interview high-frequency questions] Linked list high-frequency questions that can be gradually optimized
- 微信支付开发流程
- 我们真的需要DApp吗?App真的不能满足我们的幻想吗?
- JD.com architects tidy up: what are the core technical knowledge points of jvm and performance tuning
- MongoDB-查询中$all的用法介绍
- [Essence] Analysis of the special case of C language structure: structure pointer / basic data type pointer, pointing to other structures
- TIC2000调用API函数Flash擦除片上FLASH失败
- 鹅厂机器狗花式穿越10m梅花桩:前空翻、单桩跳、起身作揖...全程不打一个趔趄...
- matlab simulink的scope 示波器光标如何移动记录
- redis库没法引入
猜你喜欢
Semaphore SIGCHLD use, how to make the parent that the child performs over, how to make the distinction between multiple child processes. The end
[Essence] Analysis of the special case of C language structure: structure pointer / basic data type pointer, pointing to other structures
微信一面:一致性哈希是什么,使用场景,解决了什么问题?
C# Get system installed .NET version
【Adobe Premiere Pro 2020】pr2020安装和基本操作【PR安装、新建项目流程、导入及管理素材项目文件、添加标记、创建出入点剪辑视频、快速剪接及自动音乐卡点的方法
字符串 | 反转字符串 | 双指针法 | leecode刷题笔记
读写分离后,性能居然提升100%了呀
京东架构师呕心整理:jvm与性能调优有哪些核心技术知识点
HAproxy:负载均衡
IDEA 关闭/开启引用提示Usages
随机推荐
2022 Niu Ke Duo School (6) M. Z-Game on grid
GRPC整体学习
父类的main方法可以被继承么?有什么特殊?
Byte Qiu Zhao confused me on both sides, and asked me under what circumstances would the SYN message be discarded?
修改VOT2018.json文件,去掉图片路径中的color
未来装备探索:数字孪生装备
Reading and writing after separation, performance were up 100%
从零开始Blazor Server(9)--修改Layout
TIC2000系列处理器在线升级
GET请求和POST请求区别
BISS绝对值编码器_TI方案_线路延迟补偿
The grep command Shell regular expressions, the three musketeers
【Untitled】
MySQL查询性能优化七种武器之索引潜水
结构体变量的首地址获取注意事项
MySQL中的锁
matlab simulink的scope 示波器光标如何移动记录
【重要】C语言进阶 -- 自定义类型:结构体、枚举、联合
900页数学论文证明旋转的黑洞不会爆炸,丘成桐:30多年来广义相对论首次重大突破...
湖南进芯电子替代TIC2000的可能性