企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
直接输出字符串 通过beego.Controller.Ctx.WriteString()方法可以直接向http response body中输出字符串 ~~~ |-- routers | `-- router.go ~~~ ~~~ package routers import ( admin "project/admin/controllers" "github.com/astaxie/beego" ) func init() { // 固定路由也就是全匹配的路由 beego.Router("/admin/user/index", &admin.UserController{}, "*:Index") } ~~~ ~~~ |-- admin | |--controllers | `-- user.go ~~~ ~~~ package admin import ( "github.com/astaxie/beego" ) type UserController struct { beego.Controller } func (this *UserController) Index() { this.Ctx.WriteString("页面输出字符串") } ~~~ 浏览器访问: http://127.0.0.1:8080/admin/user/index 浏览器输出: ~~~ 页面输出字符串 ~~~