CNode

express 路由配置

问答
Rrazor1895发布于11 年前最后回复11 年前4 回复5307 浏览0 收藏

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

查看回复

回复 (4)

D
DevinXian#1·11 年前
引用 chinghanhoreq.query An object containing a property for each query string parameter in the route. If there...

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

J
jx-zhou#2·11 年前

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

H
HyperJianXin#3·11 年前

URl.png

C
chinghanho#4·11 年前

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

参与回复
登录后即可参与回复。登录