两种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/*")是设置前端页面目录

最新文章

  1. Improve Your Study Habits
  2. Java NIO 之缓冲区
  3. 再看静态static及相关知识汇集
  4. jenkins2 pipeline介绍
  5. 详解Paint的setMaskFilter(MaskFilter maskfilter)
  6. 书写CSS需要注意的地方
  7. java ant 命令大全
  8. [LeetCode] Largest Rectangle in Histogram 解题思路
  9. Nginx fastcgi_param解释
  10. Universal-Image-Loader 基本使用
  11. 子级Repeater获取 父级Repeater
  12. mcstructs使用CMake生成Makefile文件
  13. MUI开发大全
  14. [爬虫]采用Go语言爬取天猫商品页面
  15. macOS 10.13 High Sierra odoo11 开发配置--完整版
  16. 全连接与softmax[转载]
  17. JQuery进度条
  18. Linux内存管理学习3 —— head.S中的段页表的建立
  19. Flutter学习之制作底部菜单导航
  20. Maven实战(九)---模块聚合和继承

热门文章

  1. CORS-跨域问题:Access-Control-Allow-Origin Header and the ASP.NET Web API
  2. Python | Pipenv官方推荐的python包管理工具
  3. DispatcherServlet 被加载顺序
  4. centos7.6环境编译安装php-7.2.24修复最新 CVE-2019-11043 漏洞
  5. [LeetCode] 359. Logger Rate Limiter 记录速率限制器
  6. jmap使用
  7. namespace Measure
  8. android基础---->SharedPreferences的使用
  9. 第4/7Beta冲刺
  10. Windows网络命令的相关指令(1)