日期:2014-05-16 浏览次数:20408 次
若url为:
http://localhost:8888/select?name=a&id=5
http.createServer(function(request,response){ var pathname = url.parse(request.url).pathname; //pathname => select var arg = url.parse(request.url).query; //arg => name=a&id=5 console.log("Request for " + arg ); var name = querystring.parse(arg).name; //name => a console.log("name = "+name); console.log("Request for " + pathname + " received."); }).listen(8888);
//querystring.parse(arg) => { name: 'a', id: '5' }
更多信息:
http://nodejs.org/api/url.html