Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用单独模块时快速路由和URL解析_Node.js_Express_Module_Routing - Fatal编程技术网

Node.js 使用单独模块时快速路由和URL解析

Node.js 使用单独模块时快速路由和URL解析,node.js,express,module,routing,Node.js,Express,Module,Routing,我希望能够解析数据的url查询,并在响应中使用它。在我的应用程序文件中,我有以下内容: var entry = require('./routes/entry'); app.use('/entry*', entry); 在我的路线文件中: router.get('/:name', function(req, res) { res.send(req.params.name); }); module.exports = router; 目前我得到一个404错误 我想知道如何从url中获取名

我希望能够解析数据的url查询,并在响应中使用它。在我的应用程序文件中,我有以下内容:

var entry = require('./routes/entry');
app.use('/entry*', entry);
在我的路线文件中:

router.get('/:name', function(req, res) {
  res.send(req.params.name);
});

module.exports = router;
目前我得到一个404错误

我想知道如何从url中获取名称参数。因此,如果有人键入…/entry/example,那么响应将是“example”


我的很多困惑源于路由器应该处理什么以及app.use应该将什么作为其URL参数。非常感谢

从/entry中删除星号*,它将按预期开始工作。我创建了一个本地express应用程序,插入星号会导致相同的问题