环境:
JDK:1.6
浏览器:IE8
最近项目和服务器结构都发生了调整,完了后在Java里下载文件时,有时会遇到下面的错误:
Internet Explorer无法打开该Internet站点.请求的站点不可用,或找不到.请以后再试.
解决方法下有面几种:
>>A:使用下面的代码让IE识别下载的二进制文件
response.setHeader("Content-Transfer-Encoding","binary");
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
>>B:清除缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
>>C:重置HttpServletResponse
HttpServletResponse.reset()