索引.go
package main
import (
"html/template"
"net/http"
)
func viewHandler(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("index.html")
t.Execute(w, nil)
}
func main() {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
http.HandleFunc("/index", viewHandler)
http.ListenAndServe(":8080", nil)
}
在我的 index.html 中,我使用了以下路径
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css">
.css 的路径如下,
网页(文件夹)
|---index.go
|---静态/css/xxx.css
但是,css 不包含在 html 中。如何更改代码以解决此问题