2 回答

TA貢獻1155條經(jīng)驗 獲得超0個贊
在路由文件中添加這兩行。這里所有的 GET 請求都將轉(zhuǎn)移到應(yīng)用程序控制器的索引函數(shù)。
GET / App.Index
GET /* App.Index
在應(yīng)用程序控制器文件中添加以下代碼。
func (c App) Index() revel.Result {
dir, doc := path.Split(c.Request.URL.Path)
ext := filepath.Ext(doc)
if doc == "" || ext == "" {
return c.RenderFileName("./public/index.html", "inline")
} else {
if _, err := os.Stat("./public/" + path.Join(dir, doc)); err != nil {
return c.RenderFileName("./public/index.html", "inline")
}
return c.RenderFileName("./public/" + path.Join(dir, doc), "inline")
}
}

TA貢獻1780條經(jīng)驗 獲得超5個贊
沒什么大不了的,你離得很近
GET / Static.Serve("public/index.html")
然后你的角度應(yīng)該做他的工作。
- 2 回答
- 0 關(guān)注
- 125 瀏覽
添加回答
舉報