【发布时间】:2014-09-29 18:18:30
【问题描述】:
我有一个公共目录,其中包含文件 index.html 和 index-08.html。
使用下面的代码,我希望 index-08.html 能够得到服务。但是,index.html 会通过 localhost:3000 的浏览器请求提供服务
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
res.sendFile('public/index-08.html');
});
但是,如果我将 index.html 的文件名更改为其他名称,例如 not-index.html,则正确的文件 index-08.html 会得到服务。
你能帮我理解为什么会这样吗?
【问题讨论】: