【发布时间】:2016-07-28 13:16:05
【问题描述】:
我正在尝试使路线动态像 /review-{title}-{id} ,但导致错误不知道为什么,如果用户输入错误的参数而不是如何处理。 我的客户要求如上所述,我不擅长节点并表达请任何人建议如何制作上述路线。 另外,如果我需要像这样 /review/:title/:id 格式制作路线,我该怎么做。
我正在尝试,但它会将我重定向到 404 页面,
请在里面找到我现有的代码详细信息, server.js
this is working..
app.get('/review', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/review.html'));
});
but not this one..
app.get('/review-*-*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/review.html'));
});
Also not this one working
app.get('/review/*/*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/review.html'));
});
This is 404 page which call evrytime while accessing dynamic pages
app.get('/*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client/404.html'));
});
【问题讨论】:
标签: node.js express routes js-routes