Fork me on GitHub

04 2022 档案

摘要:一、问题引出 如果通过前端向后端传递数据,你可能会这样进行接收: 1、前台 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action= 阅读全文
posted @ 2022-04-17 13:47 iveBoy 阅读(565) 评论(0) 推荐(0) 编辑
摘要:一、自带函数 (一)print系列 1、简介 在go语言中的fmt包中存在: Print系列 Sprint系列 那么它们之间的区别是什么呢? package main import "fmt" func main() { name := "lily" fmt.Print(name) // Print 阅读全文
posted @ 2022-04-17 10:22 iveBoy 阅读(632) 评论(0) 推荐(0) 编辑
摘要:在Gin框架模板中使用 {{ }} 括号进行变量渲染,那么它自带有一些语法用法。 一、上下文 . 访问当前位置的上下文 . 引用模板中的根级上下文 后台: package main import ( "github.com/gin-gonic/gin" "net/ht 阅读全文
posted @ 2022-04-14 07:33 iveBoy 阅读(1906) 评论(0) 推荐(0) 编辑
摘要:一、Form表单上传 (一)单文件上传 前端 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action="/post_upload" 阅读全文
posted @ 2022-04-10 19:36 iveBoy 阅读(701) 评论(0) 推荐(0) 编辑
摘要:一、GET请求处理 (一)路径参数 对于类似这样的请求:http://127.0.0.1:8080/index/12,那么如何获取最后路径中12的值呢? package main import ( "fmt" "github.com/gin-gonic/gin" "net/http" ) func 阅读全文
posted @ 2022-04-10 11:13 iveBoy 阅读(997) 评论(0) 推荐(0) 编辑
摘要:一、结构体 1、后端 package main import ( "github.com/gin-gonic/gin" "net/http" ) type User struct { Id int Name string Age int } func StructDemo(ctx *gin.Cont 阅读全文
posted @ 2022-04-09 20:26 iveBoy 阅读(201) 评论(0) 推荐(0) 编辑
摘要:一、模板的使用 1、加载模板路径 当使用gin.Default方法创建一个router后需要加载模板路径,加载的方法可以使用: LoadHTMLGlob 只有一个参数,通配符,如:router.LoadHTMLGlob("templates/*"),查找当前项目路径下template文件夹下所有的h 阅读全文
posted @ 2022-04-09 12:16 iveBoy 阅读(1446) 评论(0) 推荐(0) 编辑

TOP
点击右上角即可分享
微信分享提示