gin中映射查询字符串或表单参数

package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.GET("/", func(context *gin.Context) {
		// 查询字符串映射 (http://127.0.0.1:3000?ids[a]=1234&ids[b]=hello)
		ids := context.QueryMap("ids")
		fmt.Println(ids)
		// 表单参数 数组
		names := context.PostFormArray("names")
		fmt.Println(names)
		context.String(200, "OK")
	})
	r.Run()
}

  

 

posted @ 2021-10-27 14:44  专职  阅读(87)  评论(0编辑  收藏  举报