nodejs实现获取当前url地址及url各种参数值
//需要使用的模块http url 当前url http://localhost:8888/select?aa=001&bb=002 varhttp=require('http'); varURL=require('url'); http.createServer(function(req,res){ vararg=url.parse(req.url).query; //方法一arg=>aa=001&bb=002 vararg=url.parse(req.url,true).query; //方法二arg=>{aa:'001',bb:'002'} console.log(arg.aa);//返回001 console.log(arg.bb);//返回002 //然后就可以根据所得到的数据处理了
}).listen(8888);//建立服务器并监听端口