当浏览者访问一个网页时,浏览者的浏览器会向网页所在服务器发出请求。 当浏览器接收并显示网页前,此网页所在的服务器会返回一个包含HTTP状态码的信息头(server header)用以响应浏览器的请求。 HTTP状态码的英文为HTTP Status Code。
下面是常见的HTTP状态码:
附录:
阅读原文: https://blog.mazey.net/1931.html
function readLog(date,type,operation){//函数接受3个参数,日期、精度(天时分秒)和操作(查找、刷新或者默认) if(date){ //如果有时间参数则对时间参数进行处理(一般日志名称都是时间加类型) var dataStr = arguments[0] var date = dataStr.slice(0,10) var hour = dataStr.slice(11,13) var minute = dataStr.slice(11,16) var second =dataStr.slice(11,19) var type = arguments[1] //获取精度}else{ //若无时间参数则获取当前时间,然后精度默认 var date = new Date(+new Date()+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'').slice(0,10) var type=null
} var op = arguments[2] var countResult = 0 //对日志结果进行统计 var logPath = appDirName.slice(0,-3)+'log\\'+'ivsvr_'+date+'.log' //拼接日志文件名称 var logStr = ''
fs.stat(logPath, function (err, stats) { //获取对应的日志文件状态 if(err){ //日志不存在或者异常处理信息
$('#logTipInfo tr td').html('无日志信息可供查看') console.log(err)
}else{ var lineCount = 0 var readline = require('readline') var fReadName = logPath var fRead = fs.createReadStream(fReadName) var objReadline = readline.createInterface({ input: fRead,
}) //按行读取日志
objReadline.on('line', (line)=>{ var itemStr = $.trim(line) var time = itemStr.slice(0,19) var content = itemStr.substr(20) if(!time || !content){return}
++ lineCount //计数行数 var matched = true var itemStr = $.trim(line) var itemArr = itemStr.split(' ') var logDate = itemArr[0] var logTime = itemArr[1] var time = logDate+' '+logTime switch(type){ //进度查找过滤 case '0': case null:
matched = true break case '1': var timeSplit = logTime.slice(0,2) if(timeSplit == hour){
matched = true break
}
matched = false break case '2': var timeSplit = logTime.slice(0,5) if(timeSplit == minute){
matched = true break
}
matched = false break case '3': var timeSplit = logTime.slice(0,8) if(timeSplit == second){
matched = true break
}
matched = false break default: console.log('unkonw type!') break
} if(matched === true &&(lineCount>logReadFlag)){ //日志结果格式化输出呈现
countResult ++ var result = itemArr[2] if(result == 'err'){ var operation = itemArr[4]
result = '失败:'+itemArr[5]+' '+(itemArr[6]?itemArr[6]:'')
}else{ var operation = itemArr[4]+' '+itemArr[5]+(itemArr[6]?itemArr[6]:'')
result = '成功'
}
logStr += '<tr><td>'+time+'</td><td>'+operation+'</td><td>'+result+'</td></tr>'
}
logStr += '<tr><td>'+time+'</td><td>'+content+'</td></tr>'
}) objReadline.on('close', ()=>{ if(logReadFlag == 0 && (logStr == '')){ var info = '无日志信息可供查看'
} if(logReadFlag >0 && (logStr != '')){ var newLogNum = lineCount - logReadFlag var info = '刷新成功,更新'+newLogNum+'条日志!'
$('#logInfoTable').prepend(logStr)
}else if(logReadFlag >0 && (logStr == '')){ var info = '刷新成功,无日志更新!'
}else{
$('#logInfoTable').html(logStr)
} if(op == 'search'){ var info = '查找到'+countResult+'条日志'
}
$('#logTipInfo tr td').html(info) if((op == 'search' || op == 'refresh') &&(logReadFlag != 0 || newLogNum >0 || countResult >0)){
setTimeout(function() {$('#logTipInfo').fadeOut(567)}, 2000) //操作结束后给出信息反馈,反馈自动淡出消失
} else{
$('#logTipInfo').hide()
}
logReadFlag = lineCount console.log('closed')
})
}
})
}
js获取response对象1.
response主要方法方法名称作用setHeader(name,value)设置响应信息头setContentType (String)设置响应文件类型、响应式的编码格式setCharacterEncoding(String)设置服务端响应内容编码格式getWriter()获取字符输出流
2.
response应用Java复制代码 1//获取请求参数代码省略2//获取输出流3PrintWriter out=response.getWriter()4out.println("<html>")5out.println("<head ISO8859-1编码响应内容
3.
解决输出中文乱码●设置服务器端响应的编码格式●设置客户端响应内容的头内容的