设为首页 加入收藏

TOP

node.js 接收get请求
2014-11-24 14:28:27 来源: 作者: 【 】 浏览:2
Tags:node.js 接收 get 请求

Get 请求的相关方法一定在http.ServerRequest下,ServerRequest有data、end、close3个事件,method、url、headers、trailers、httpVersion、connection6个属性,setEncoding、pause、resume3个方法。


url属性下有一段说明描述了怎么解析get请求:




Request URL string. This contains only the URL that is present in the actual HTTP request. If the request is:


Then request.url will be:


If you would like to parse the URL into its parts, you can use require('url').parse(request.url). Example:


If you would like to extract the params from the query string, you can use therequire('querystring').parse function, or pass true as the second argument to require('url').parse. Example:


按照说明试一下吧(node> 表示 在命令行里敲代码)




那就结合 hello world 写一个动态的hello world




在浏览器地址栏中敲入 http://127.0.0.1:1337/hello name=myname




】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇node.js 分析hello world的例子 下一篇node.js 接收post请求

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: