2014-08-28 91 views
0

我想渲染外部样式表。我不知道这是为什么不工作:转:无法渲染外部样式表

GO:

func main() { 
    http.HandleFunc("/", homeHandler) 
    http.HandleFunc("/image/", imageHandler) 
    http.Handle("/layout/", http.StripPrefix("/layout/", http.FileServer(http.Dir("layout")))) 

    http.ListenAndServe(":8000", nil) 
} 

导演结构:

gocode 
    layout 
     stylesheets 
      home.css 
    home.html 
main.go 

HTML:

<link rel="stylesheet" type="text/css" href="/stylesheets/home.css" /> 

的哪些错误?我跟着这里的例子:Rendering CSS in a Go Web Application

回答

3

你的文件服务器是/layout/,所以它应该是

<link rel="stylesheet" type="text/css" href="/layout/stylesheets/home.css" />