2 回答

TA貢獻1155條經驗 獲得超0個贊
在路由文件中添加這兩行。這里所有的 GET 請求都將轉移到應用程序控制器的索引函數。
GET / App.Index
GET /* App.Index
在應用程序控制器文件中添加以下代碼。
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")
}
}
- 2 回答
- 0 關注
- 129 瀏覽
添加回答
舉報