gin 页面重定向 |
您所在的位置:网站首页 › gin重定向 › gin 页面重定向 |
两种gin页面重定向方式 redirect: package main import ( "github.com/gin-gonic/gin" "net/http" ) func main() { r := gin.Default() r.GET("/redirect", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently,"http://www.baidu.com") }) r.Run(":8080") }html rendering: func main() { router := gin.Default() router.LoadHTMLGlob("templates/*") router.GET("/index", func(c *gin.Context) { c.HTML(http.StatusOK, "index.tmpl", gin.H{ "title": "Main website", }) }) router.Run(":8080") }其中 router.LoadHTMLGlob("templates/*")是设置前端页面目录 |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |