标签:
1、req.query 处理GET请求 ,获取GET参数
//GET /search?q=tobi+ferret
req.query.q
//=>"tobi ferret"
//GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse
req.query.order
//=>"desc"
req.query.shoe.color
//=>"blue"
2、req.body 处理POST请求,获取POST参数
//POST user[name]=tobi&user[email]=tobi@qq.com
req.body.user.name
//=>"tobi"
//POST {"name": "tobi"}
req.body.name
//=>"tobi"
3、req.params 处理/xxx形式的GET/POST请求
//GET /user/tj
req.params.user
//=>"tj"
//GET /js/javascript/jquery.js
req.params[0]
//=>"javascript/jquery.js"
4、req.param() 处理GET/POST请求,但查找优先级由高到低为 req.params-->req.body-->req.query
//?name=tobi
req.param(‘name‘)
//=>"tobi"
//POST name=tobi
req.param(‘name‘)
//=>"tobi"
标签:
原文地址:http://my.oschina.net/xiax/blog/485353