求助JQuery XMLHTTP 如何处理GZIP压缩数据
发布网友
发布时间:2022-04-22 20:06
我来回答
共1个回答
热心网友
时间:2022-04-22 21:36
JavaScript Ajax
用GZIP压缩后, JQuery XMLHTTP获取的Response Data 如何显示
success: function(data) {
}
Servlet doPost
Java代码
String encoding = request.getHeader("Accept-Encoding");
if (encoding != null && encoding.indexOf("gzip") != -1){
response.setHeader("Content-Encoding" ,"gzip");
out = new GZIPOutputStream(response.getOutputStream());
} else if (encoding != null && encoding.indexOf("comdivss") != -1){
response.setHeader("Content-Encoding" , "comdivss");
out = new ZipOutputStream(response.getOutputStream());
}else{
out = response.getOutputStream();
}
PrintWriter writer=new PrintWriter(out);
writer.write("resp data");
writer.flush();