一、获取表单提交的数据
1.contxt.PostForm(“username”) 获取表单中的name属性对应的值
前端:submit提交
<form action="/hello_add" method="post">
<input type="text" name="username"><br>
<input type="text" name="age"><br>
<input type="submit" value="提交">
</form>
后端:
func IndexAdd(contxt *gin.Context) {
name := contxt.PostForm("username")
age := contxt.PostForm("age")
contxt.String(200,"hello,%s,年龄为:%s",name,age)
}
func main() {
eng