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")

正在整理筆記,如雷同,請告知,必添加!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM