express 路由配置
 发布于 10 年前  作者 razor1895  5110 次预览  最后一次回复是 10 年前  来自 问答 

我想知道像这样 http://localhost:3000/calendar/event?action=add&date=2015-02-01 的url应该怎样在express路由里面配置才能获取到后面的日期

4 回复
jx-zhou

路由和正常的一样,后面的可以作为传入参数在req参数中。

chinghanho

req.query

An object containing a property for each query string parameter in the route. If there is no query string, it is the empty object, {}.

http://expressjs.com/api.html#req.query

DevinXian

@chinghanho 正解,不管你是req的method是POST还是GET,url中的参数都被解析到req.query里去了。可以自己使用url模块实验下…如果没记错,url里面也用的是querystring…@HyperJianXin