【发布时间】:2014-08-17 07:38:19
【问题描述】:
我在下面提供 html 模板的方式有问题吗?页面上没有任何内容。
twitter.go:
func loghandler(w http.ResponseWriter, r *http.Request) {
t := template.Must(template.New("tele").ParseFiles("layout/log.html"))
t.Execute(w, nil)
}
log.html:
<html>
<form action="/login" method="POST">
<label for="name">Username</label>
<input type="text" id="Username" name="name"></input>
<button type="submit">Login</button>
</form>
</html>
目录结构:
twitter
layout
log.html
twitter.go
【问题讨论】:
-
您检查错误了吗?
-
if err := t.Execute(w, nil); err != nil { panic(err) } -
它说 html/template:tele: "tele" 是一个不完整或空的模板
-
之前的错误信息是:open layout/log.html: no such file or directory
-
默不作声的小仙女们好烦。
标签: go