golang两种get请求获取携带参数的方式

1、  ?id=2&name=hello

    id := context.Query("id")
    name := context.Request.URL.Query().Get("name")
    var u model.User
   if context.Bind(&u) == nil {
        fmt.Println(u.Id)

 

2、  /user/2/hello

// 获取请求参数
    id := context.Param("id")
    name := context.Param("username")

正在整理笔记,如雷同,请告知,必添加!

posted on 2020-08-07 18:38  Hi,Bro  阅读(3078)  评论(0编辑  收藏  举报