zoukankan      html  css  js  c++  java
  • 获取Get和Post参数

    func main() {
    
    	// /post?id=1234&page=1 HTTP/1.1
    	router := gin.Default()
    
    	router.POST("/post", func(c *gin.Context) {
    
    		id := c.Query("id")
    		page := c.DefaultQuery("page", "0")
    		name := c.PostForm("name")
    		message := c.PostForm("message")
    
    		c.JSON(200, gin.H{
    			"id": id,
    			"page": page,
    			"name": name,
    			"message": message,
    		})
    	})
    
    	router.Run(":8080")
    }
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
    <form action="http://127.0.0.1:8080/post?id=1234&page=1 HTTP/1.1" method="post" action="application/x-www-form-urlencoded">
        用户名:<input type="text" name="name" placeholder="请输入你的用户名">  <br>
        密   码:<input type="password" name="message" placeholder="请输入你的密码">  <br>
        <input type="submit" value="提交">
    </form>
    </body>
    </html>
    

     

  • 相关阅读:
    有关敏捷(1)
    有关创业的想法
    2010必须做到的事
    技术搜索还是谷歌强
    错误处理的一些想法
    定期自动删除数据
    ip
    asp.ent Repeter实现分页
    QQ客服在线聊天
    几种文件上传的方法
  • 原文地址:https://www.cnblogs.com/yzg-14/p/13141898.html
Copyright © 2011-2022 走看看