自动路由下的urlfor
URL构建与控制器关系(路由绑定)
beego.UrlFor函数返回控制器方法所返回的url
router => url controller
AutoRouter => controller => URL(controller/action)
controller.Action => url
beego.UrlFor => Controller.Redirect => URL =>beego.UrlFor=>template a.href/form.action => URL=> urlfor
在控制器中
c.Redirect("/user/query",302) //跳转可以使用urlfor
// fmt.Println(beego.URLFor("UserController.Query"))
// 使用urlfor c.Redirect(beego.URLFor("UserController.Query"),302)
return
在模板中
<a class="nav-link" href="{{ urlfor `UserController.Query` }}">模板中使用urlfor</a>
文档更新时间: 2023-08-08 18:47 作者:张尚