public void dGet(HttpSerletRequest request,HttpServletResponse response) throws ServletException,IOException{
response.setContentType("APPLICATION/ZIP;charset=GBK");
response.setHeader("Content-Disposition","attachment;filename="test.zip");
ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream);
zipOut.putNextEntry("file1.zip");
zipOut.write("zip1".getBytes());
zipOut.putNextEntry("file2.zip");
zipOut.write("zip2".getBytes());
zipOut.putNextEntry("file3.zip");
zipOut.write("zip3".getBytes());
zipOut.close();
}
以上代碼在resin環境下可以下載到test.zip並可以成功解壓
而在weblogic環境下雖然可以下載,但下載後的文件卻不能解壓,提示 “壓縮文件損壞”
將
response.setContentType("APPLICATION/ZIP;charset=GBK"); GBK換成 UTF-8或 ISO8859-1