【发布时间】:2014-07-30 17:06:55
【问题描述】:
在本地主机上使用 express 3.5.1 我的 app.js 文件中有
app.use(express.static(path.join(__dirname, 'public')));
我的 style.css 文件在 public/stylesheets 中
在我的 page.jade 文件中
doctype html
html
head
link(rel = "stylesheet" href = "stylesheets/style.css")
body
// more stuff here
最后,在我的路线中,我有
app.get('/path', dostuff);
app.get('/path/:param', dostuff);
function dostuff(req,res) {
res.render('page');
}
现在,当我转到 localhost:3000/path 时,一切都很好,并且包含 style.css。但是我转到 localhost:3000/path/anything,页面仍然呈现,但是我碰巧包含的任何样式表都会出现 404 错误,即使功能完全相同。为什么会这样?是否有人四处寻找似乎无法找到此特定案例的答案。
【问题讨论】:
标签: css node.js express parameters pug