0

索引.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 中。如何更改代码以解决此问题

4

1 回答 1

-1

由于端口冲突,没有正确包含 CSS 文件。感谢@Intermernet。:)

于 2015-06-28T11:38:53.680 回答