node.js 获取http url路径中的各个参数
2013-01-29 18:02
671 查看
若url为:
http://localhost:8888/select?name=a&id=5
//querystring.parse(arg) => { name: 'a', id: '5' }
更多信息: http://nodejs.org/api/url.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 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);
//querystring.parse(arg) => { name: 'a', id: '5' }
更多信息: http://nodejs.org/api/url.html
相关文章推荐
- node.js 获取http url路径中的各个参数
- node.js 获取http url路径中的各个参数 .
- 实例讲解node.js解析URL并获取绝对路径和格式化
- node.js 获取url中的各个参数
- js解析url参数如http://www.taobao.com/index.php?key0=21&key1=你哈&(获取key0和key1的值)
- js获取当前域名、Url、相对路径和参数
- js获取url路径参数
- Node.js中的express框架获取http参数
- Nodejs express 获取url参数,post参数的三种方式
- 2017_12_15 js获取项目路径,js调用问题,jsp获取js传递url中参数
- js获取当前域名、Url、相对路径和参数
- js_html_input中autocomplete="off"在chrom中失效的解决办法 使用JS模拟锚点跳转 js如何获取url参数 C#模拟httpwebrequest请求_向服务器模拟cookie发送 实习期学到的技术(一) LinqPad的变量比较功能 ASP.NET EF 使用LinqPad 快速学习Linq
- 获取当前页面url中的参数 coffeescript+node.js+angular
- Node.js中的express框架获取http参数
- js 获取url路径中?后面参数的值
- js修改iframe框架的src路径及js获取URL的get参数中文乱码的问题
- js获取当前域名、Url、相对路径和参数以及指定参数
- Nodejs express 获取url参数,post参数的三种方式
- js获取当前Url网址路径及参数 location.hostname
- JS获取URL参数