站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题求教JSP页面中文件下载的错误问题

求教JSP页面中文件下载的错误问题

摘要: 求教JSP页面中文件下载的错误问题


download.jsp代码

<%@ page import="java.io.FileInputStream"%>
<%@ page import="java.io.OutputStream" %>
<%
String fileUrl=(String) request.getParameter("fileUrl");
String fileName=(String) request.getParameter("fileName");
System.out.println(fileUrl);
try{
FileInputStream bis = new FileInputStream(fileUrl.trim());
response.setHeader("Content-disposition","attachment; filename=/""+fileName+"/"");
OutputStream bos = response.getOutputStream();
byte[] buff = new byte[1024];
int readCount = 0;
int i = 0;
readCount = bis.read(buff);
while (readCount != -1){
bos.write(buff, 0, readCount);
readCount = bis.read(buff);
}
if (bis!=null) bis.close();
if (bos!=null) bos.close();
}catch(Exception e){
e.printStackTrace();
out.println("error.message"+e.getMessage());
}
%>

错误信息:
(The system cannot find the path specified)

程序当中打印出来的文件是可以正常显示,且fileUrl中的文件于本机上是存在的,但就下载时老提示找不到文件,请各位大侠帮忙解决下,谢谢


没人看。。。自己顶下


晕,程序一切正常呀.


问题解决了,原来是搞错了下载文件的扩展名,结果下载下来的文件格式不对,就产生了乱码问题。。。还是感谢iwlk(第六世纪)的回复,哈


↑返回目录
前一篇: 多选列表的问题
后一篇: 有关class.forname调用的一个问题?