【发布时间】:2014-03-03 10:36:26
【问题描述】:
我正在尝试压缩控制器操作的输出以节省一些带宽:
new ByteArrayOutputStream().withStream{ baos ->
new GZIPOutputStream( baos ).withWriter{ it << m.text.bytes }
//def gzip = baos.toByteArray().encodeBase64()
def gzip = new String( baos.toByteArray() )
response.setHeader 'Content-Type', 'application/x-javascript'
response.setHeader 'Content-Encoding', 'x-gzip'
response.outputStream.withStream{ it << gzip }
}
}
当我在浏览器中打开网址时,它会显示给我
未知错误:net::ERR_CONTENT_DECODEDING_FAILED
在 IE 中 或
内容编码错误
在FF中
我错过了什么?
【问题讨论】:
-
您能检查一下您是否没有使用 utf-8 BOM 保存文件吗? (stackoverflow.com/questions/2223882/…) 你需要一个好的编辑器才能注意到其中的差异。
-
另外,如果打开了 php error_reporting,这可能会出现问题。
-
不,不存在BOM问题,与php无关