如何使用Express解析querystring中的变量? [英] How to parse variables in querystring using Express?
本文介绍了如何使用Express解析querystring中的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个请求发送到服务器:
I have a request being sent to the server:
"/stuff?a=a&b=b&c=c"
使用express,如何获取这些值?
Using express, how do I get these values?
我尝试了以下...
app.get( "/stuff?:a&:b&:c", function( req, res ){});
...但是似乎不认识路线。
...however it does not seem to recognize the route.
感谢(提前)为您的帮助。
Thanks (in advance) for your help.
推荐答案
使用查询不是一个好主意在路由中的字符串。
It's not a good idea to use a query string inside a route.
在Express逻辑中,您需要为/ stuff创建路由。查询字符串将在 req.query
中可用。
In Express logic you need create a route for "/stuff". The query string will be available in req.query
.
这篇关于如何使用Express解析querystring中的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文