node.js中的http.response.write方法使用说明
2023-06-13 09:15:32 时间
方法说明:
向请求的客户端发送响应内容。
在response.end()之前,response.write()可以被执行多次。
语法:
response.write(chunk,[encoding])
参数:
chunk 是一个buffer或字符串,表示发送的内容
encoding 如果chunk是字符串,就需要指定encoding来说明它的编码方式,默认utf-8
例子:
varhttp=require("http");
http.createServer(function(req,res){
res.writeHead(200,{"Content-type":"text/html"});
res.write("<h1>Node.js</h1>");
res.end("<p>HelloWorld</p>");
}).listen(3000);
相关文章
- js对象转数组 entries方法
- JS面试题-JS实现继承的方法(共6种)
- js中四舍五入的方法_JS取整
- JS replaceChild()方法:替换节点
- JS compile()方法:编译正则表达式
- JS every()方法:检测数组元素是否全部符合指定条件
- JS getAttribute()方法:读取元素的属性值
- 使用Node.js实现对MSSQL数据库的连接(node连接 mssql)
- 利用Node.js实现对MS SQL服务器的连接(node连MSsql)
- asp.net中js和jquery调用ashx的不同方法分享
- js编码转换gb2312和utf8互转的2种方法
- 使用Node.js做FunctionTest实现方法
- 前台js调用后台方法示例
- js生成动态表格并为每个单元格添加单击事件的方法
- js数组操作常用方法
- node.js中的console.warn方法使用说明
- node.js中的querystring.unescape方法使用说明
- node.js中的events.emitter.once方法使用说明
- node.js中的buffer.fill方法使用说明
- node.js中的http.get方法使用说明
- node.js中的fs.fstatSync方法使用说明
- node.js中的fs.exists方法使用说明
- node.js中的fs.createWriteStream方法使用说明
- 使用jquery动态加载js文件的方法
- js获取checkbox值的方法