3
0
镜像自地址 https://github.com/gin-gonic/gin.git 已同步 2026-12-03 09:43:36 +08:00

Update README.md

这个提交包含在:
Justin Beckwith 2015-05-26 08:11:20 -07:00
父节点 8d812a2097
当前提交 b7253902d0

查看文件

@ -144,17 +144,17 @@ func main() {
#### Querystring parameters
```go
func main() {
r := gin.Default()
// Query string parameters are parsed using the existing underlying request object.
// The request responds to a url matching: /search?firstname=Jane&lastname=Doe
r.GET("/search", func(c *gin.Context) {
firstname := c.Request.URL.Query().Get("firstname")
lastname := c.Request.URL.Quert().Get("lastname")
message := "Hello " + firstname + lastname
c.String(http.StatusOK, message)
})
r.Run(":8080")
router := gin.Default()
// Query string parameters are parsed using the existing underlying request object.
// The request responds to a url matching: /welcome?firstname=Jane&lastname=Doe
router.GET("/welcome", func(c *gin.Context) {
firstname := c.DefaultQuery("firstname", "Guest")
lastname := c.Query("lastname") // shortcut for c.Request.URL.Query().Get("lastname")
c.String(http.StatusOK, "Hello %s %s", firstname, lastname)
})
router.Run(":8080")
}
```