ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的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 浏览器输出: ~~~ 页面输出字符串 ~~~