关于nodejs 假设httpserver,会发现一次网页打开,服务端会响应两次的问题;
转自:http://cnodejs.org/topic/518772806d38277306804020
每个页面默认都会再发一个
de style="line-height: 21px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; font-size: 12px; color: inherit; border-radius: 3px; border: 0px; background-color: transparent;" >var http=require('http'); var i=0; var req=function(req,res){ i=i+1; console.log(i,req.url); res.writeHead(200,{'Content-Type':'text/plain'}); res.end('Hello World\n'); }; http.createServer(req).listen(8888,"127.0.0.1"); console.log('Server running...'); de> 
##控制台输出:
de style="line-height: 21px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; font-size: 12px; color: inherit; border-radius: 3px; border: 0px; background-color: transparent;" >Server running... 1 '/' 2 '/favicon.ico' de> 
posted on 2017-02-23 15:50 maomingchao 阅读(164) 评论(0) 收藏 举报
 
                    
                     
                    
                 
                    
                 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号