admin管理员组文章数量:1335854
I am trying to set a route in express js that would be triggered by any query that would start with that route Url.
For instance, I want to do the following in an html file:
<a href="/article/article1">Article 1</a>
<a href="/article/article2">Article 2</a>
and handle the 2 Url by a single route:
app.get('/article/*',function(req,res) {
// do something with req.path
}
I know static does that so there should be a way. I want to do this without using query parameters, because urls without query parameters feel more static, and I want to give the users this impression that the page will always work.
Is there something to do that?
I am trying to set a route in express js that would be triggered by any query that would start with that route Url.
For instance, I want to do the following in an html file:
<a href="/article/article1">Article 1</a>
<a href="/article/article2">Article 2</a>
and handle the 2 Url by a single route:
app.get('/article/*',function(req,res) {
// do something with req.path
}
I know static does that so there should be a way. I want to do this without using query parameters, because urls without query parameters feel more static, and I want to give the users this impression that the page will always work.
Is there something to do that?
Share Improve this question asked Feb 22, 2014 at 22:32 d--bd--b 5,7793 gold badges45 silver badges72 bronze badges 1- 1 Ah, crap, just after posting, I found out the regex thing... – d--b Commented Feb 22, 2014 at 22:35
1 Answer
Reset to default 8Turns out
app.get('/article/*',function(req,res) {
// do something with req.path
}
works fine...
本文标签: javascriptExpressjs route that responds to any subfolder get requestStack Overflow
版权声明:本文标题:javascript - Express.js route that responds to any subfolder get request - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742397877a2467290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论