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 str = querystring.parse(arg); //str=> {name:'a',id:'5'}
var arg1 = url.parse(request.url, true).query; //arg1 => {name:'a',id:'5'}
console.log("Request for " + arg1 );
var name = querystring.parse(arg).name; //name => a
console.log("name = "+name);
console.log("Request for " + pathname + " received.");
}).listen(8888);
node.js 获取http url路径中的各个参数
最新推荐文章于 2023-05-18 14:58:19 发布