脚本宝典收集整理的这篇文章主要介绍了解决使用linux部署nodejs服务测试代码返回中文是乱码,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
VAR http = require('http');
http.createServer(function (request, response) {
response.wrITeHead(200, { 'Content-tyPE': 'text/plain' });
response.end('Hello World--测试n');
}).listen(8090);
console.LOG('Server running at http://127.0.0.1:8090/');
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/htML; charset=utf-8'});//只需要设置响应头的编码格式就好,解决中文乱码问题的代码
// response.writeHead(200, { 'Content-Type': 'text/plain' }); // 原有代码
response.end('Hello World--测试n');
}).listen(8090);
console.log('Server running at http://127.0.0.1:8090/');
以上是脚本宝典为你收集整理的解决使用linux部署nodejs服务测试代码返回中文是乱码全部内容,希望文章能够帮你解决解决使用linux部署nodejs服务测试代码返回中文是乱码所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。