关于下载的问题,高手请进
我做了一个下载的servlet,在我机器上面调,当下载框出现的时候,如果点在当前位置打开的话,它不能识别是什么程序,不会自己调用程序来打开,却跳出窗口来,如果选对了程序的话,它的内容很正常.而且下载也很正常.
但是如果在另一台机器上面下载的时候.它的显示都不正常,下载以后,连后缀名都识别不了.如果点在线打开的话,要跳两次打开方式的窗口.不知道什么回事.
下面是我的代码
ServletOutputStream sos = response.getOutputStream();
String path=getServletContext().getRealPath("/");
String filepath=request.getParameter("filepath");
filepath=new String(filepath.getBytes("iso-8859-1"),"GBK");
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment;filename=\""+path+"/" + filepath + "\"");
FileInputStream fis = new FileInputStream(path+"/"+filepath);
int j;
while((j = fis.read()) != -1) {
sos.write(j);
}
sos.flush();
sos.close();
fis.close();