【发布时间】:2013-11-25 21:00:44
【问题描述】:
我是这个 node.js 的新手。我在我的 node.js 中使用 mysql。从 url 我正在构建 sql 查询。使用 1 个参数可以正常工作。
网址:
http://ipaddress:3002/users/Kappalur
通过使用以下代码,我提取了 Kappalur 及其工作正常:
app.get('/users/:level', function (req, res) {
connection.query("select * from levels where level4= '"+req.params.level+"'", function(err, rows, fields) {
res.writeHead(200, { 'Content-Type': 'application/json'});
res.end(JSON.stringify(rows,null,"\n"));
Now my requirement is i want to make "level4" to be dynamic..
现在考虑网址是:
http://ipaddress:3002/users/level4/Kappalur
现在如何更改上述代码以从 url 获取 2 个参数。帮我解决这个问题..提前谢谢。
【问题讨论】: