node.js获取httpurl路径中的各个参数.-创新互联
若url为:

网页标题:node.js获取httpurl路径中的各个参数.-创新互联
浏览地址:http://www.jxjierui.cn/article/cojhde.html

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' }
不登高山,怎知天高;不临深溪,焉知地厚!站在坚实的土地上,做着生命中最真实的事情;像一棵挺拔的大树,认可自己的命运并敢于迎接属于这一方天空的风风雨雨。网页标题:node.js获取httpurl路径中的各个参数.-创新互联
浏览地址:http://www.jxjierui.cn/article/cojhde.html


咨询
建站咨询
