go服务如何使用静态文件?

go 复制代码
package main

import "github.com/gin-gonic/gin"

func main() {
    router := gin.Default()

    // 配置第一个静态文件目录
    router.Static("/static1", "templates/static1")

    // 配置第二个静态文件目录
    router.Static("/static2", "templates/static2")

    // 启动服务器
    router.Run(":8080")
}
go服务如何使用静态文件?

app.Static 配置多个静态可以通过Static 方法。

相关推荐
聆风吟º18 小时前
【Spring Boot 报错已解决】Error creating bean with entityManagerFactory 原因分析与解决方案
java·spring boot·后端
o***741718 小时前
SpringBoot【十一】mybatis-plus实现多数据源配置,开箱即用!
spring boot·后端·mybatis
S***848818 小时前
【spring boot】 IDEA 启动springboot项目报missing ServletWebServerFactory
spring boot·后端·intellij-idea
William_cl18 小时前
【ASP.NET进阶】Controller 层 Action 返回值:HttpStatusCodeResult 状态码返回全解析
后端·asp.net
W***D45518 小时前
SpringBoot + vue 管理系统
vue.js·spring boot·后端
Ankkaya18 小时前
小白服务器踩坑
后端
拾贰_C18 小时前
[python ]anaconda
开发语言·python
VX:Fegn089518 小时前
计算机毕业设计|基于springboot + vue毕业设计选题管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·课程设计
h***673718 小时前
springboot设置多环境配置文件
java·spring boot·后端
VBA633718 小时前
VBA数据库解决方案第二十五讲:工作表中数据在数据表中批量删除
开发语言