当前位置:网站首页>golang的gin框架,各种接收参数的方式和各种绑定的区别?
golang的gin框架,各种接收参数的方式和各种绑定的区别?
2022-06-12 02:59:00 【给我一瓶冰阔洛】
1.get请求
获取url中参数?id=1234&page=1
firstname := c.DefaultQuery("firstname", "Guest")
lastname := c.Query("lastname") // 是 c.Request.URL.Query().Get("lastname") 2.post 与get请求
r.GET("/user/:name/:action" action := c.Param("action")
r.POST("/user/:name/:id" action := c.Param("id")3.post表单提交
types := c.DefaultPostForm("type", "post")
username := c.PostForm("username")
id,ok := c.GetPostForm("id")4.json 请求
parms, _ := c.GetRawData()// 定义map或结构体
var req map[string]interface{}
_ = json.Unmarshal(parms, &req)// 反序列化
fmt.Println("req",req)
jsonReq, _ := json.Marshal(req) //map转string
fmt.Println("req",jsonReq)
边栏推荐
- min25筛
- Apache simple honeypot
- Interpreting 2021 of middleware: after being reshaped by cloud nativity, it is more difficult to select models
- Demand and business model innovation - demand 8- interview
- ADB command uses JKS file to sign apk
- maya前臺渲染插件mel脚本工具
- Bochuang smart sprint technology innovation board: annual revenue of RMB 1.1 billion, book value of accounts receivable of RMB 300million
- ARD3M电动机保护器在煤炭行业中的应用
- Calculus review 2
- 推荐6款办公软件,好用还免费,效率翻倍
猜你喜欢

ACL 2022 - strong combination of pre training language model and graphic model

maya前臺渲染插件mel脚本工具

I2C协议概述

About 100 to realize the query table? Really? Let's experience the charm of amiya.

Layered architecture of DDD

安科瑞抗晃电产品在河北某化工项目的应用

ssh公钥登录失败报错:sign_and_send_pubkey: no mutual signature supported

How to prevent electrical fire in shopping malls?

A single quarter of educational technology revenue of 230million: a year-on-year decrease of 51% and a sharp narrowing of net loss

Comparaison de la taille des fractions
随机推荐
I2C协议概述
Apply concentrated load to nodes in batch in ABAQUS
Demand and business model innovation - demand 6- stakeholder analysis and hard sampling
MySQL partition table create delete modify view
Force deduction programming problem - solution summary
Wechat applet project example - I have a paintbrush (painting)
如何防止商場電氣火灾的發生?
Calculus review 2
No writing, please forgive me
ARD3M电动机保护器在煤炭行业中的应用
Maya Front Office Rendering plug - in Mel script Tool
min25筛
GeForce GTX 2050/2080/3090/A6000自动安装nvidia显卡驱动
SSH public key login failed with error: Sign_ and_ send_ pubkey: no mutual signature supported
Oracle schema object
Comparaison de la taille des fractions
Drawcall, batches, setpasscall in unity3d
laravel 8 选用 jwt 进行接口验证
The road of global evolution of vivo global mall -- multilingual solution
Paper recommendation: relicv2, can the new self supervised learning surpass supervised learning on RESNET?