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.
私はnodejs 0.8.21とexpress 3.1.0を使用しています
userIdのような URLから読み取る必要がありますhttp://mysite.com/39i。という意味userId=39です。実行する方法?ありがとうございました。サンプル:
userId
http://mysite.com/39i
userId=39
app.get('/:userId_i', function(req, res) { }); app.param('userId', function(req, res, next, id){ });
i数値の id の後に an が続き、id を数値だけで返したいと仮定します。
i
app.get("/:id([0-9]+)i", function (req, res) {...});
これは、数値の後に が続くものと一致し、 の数値iだけが得られますreq.params.id。
req.params.id
例:
curl -XGET localhost:8080/124i
で次のことを教えてくれますreq.params
req.params
[ 'id': 124 ]