Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有一些代码:
app.get(/^\/test\?sid$/, function (req, res) { console.log('sid: ', req.params[0]); res.sendfile(__dirname + '/public/login/index.html'); });
输出:
Cannot GET /test?sid
Express 的路由器只匹配路径名,而不是包括查询字符串在内的整个 URL。
由于您的正则表达式中没有捕获组,req.params因此不会设置。
req.params