站长资源
中国站长网站

node.js中的http.response.write方法使用说明

方法说明:

向请求的客户端发送响应内容。

在 response.end() 之前,response.write() 可以被执行多次。

语法:

response.write(chunk, [encoding])

参数:

chunk //是一个buffer 或 字符串,表示发送的内容

encoding //如果chunk是字符串,就需要指定encoding来说明它的编码方式,默认utf-8

例子:

var http = require('http');
http.createServer(function(req, res){
res.writeHead(200, {'Content-type' : 'text/html'});
res.write('
Node.js
');
res.end('
Hello World

');
}).listen(3000);

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » node.js中的http.response.write方法使用说明

评论 抢沙发

评论前必须登录!