2014-11-24 144 views
0

我需要设置位于“公共”文件夹中的默认页面“index.html”。我如何在Martini框架中做到这一点?如何在Martini中设置默认静态页面?

我tryed这一点,但它不工作:

func main() { 
    m := martini.Classic() 
    static := martini.Static("public", martini.StaticOptions{Fallback: "/index.html", Exclude: "/send"}) 
    m.NotFound(static, http.NotFound) 
    m.Use(static) 
    m.Get("/send", sendEmail) 
    m.Run() 
} 

回答

0

你做正确。检查您是否确实有index.html in public/文件夹,并且它是可访问的。

当前,如果回退文件不可访问,则会默默丢弃错误。

+0

我笑了。索引,html在公用文件夹中。 屏幕截图:https://yadi.sk/i/5r0_k_UTcv5WW – Pavel 2014-11-25 07:26:24

+0

你如何运行你的应用程序,你会得到什么错误? 这里是我对你的代码的测试(index.html在我的例子中包含“Hello,World”):http://imgur.com/2aI0TMO – divan 2014-11-25 07:42:46