Beego 框架学习笔记 02 | Get、Post
一、Get article.go 里添加代码: package controllers import ( "fmt" "github.com/astaxie/beego" ) type ArticleController struct { // 首字母要大写 beego.Controller } func (c *ArticleController) Get() { c.Ctx.WriteString("新闻列表") // 直接给页面返回数据 } func (c *ArticleController) AddArticle() { c.Ctx.WriteString("增加新闻") } func (c *ArticleController) EditArticle() { //获取 get 传值 id := c.GetString("id") fmt.Printf("值:%v 类型:%T", id, id) beego.Info(id) c.Ctx.WriteString("修改新闻" + id) } 展示如下: 通过 err 判断,获取 get 传值: package controllers import ( "fmt" "github.com/astaxie/beego" ) type ArticleController struct { // 首字母要大写 beego