<span style="font-size:14px;">File file = new File(filePath);
try {
InputStream fis = new BufferedInputStream(new FileInputStream(file));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
ServletActionContext.getResponse().addHeader("Content-Disposition", "attachment;filename="+filename);
ServletActionContext.getResponse().addHeader("Content-Length", "" + file.length());
ServletActionContext.getResponse().setContentType("application/vnd.ms-excel");
OutputStream os = new BufferedOutputStream(ServletActionContext.getResponse().getOutputStream());
os.write(buffer);
os.flush();
os.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}</span>
为什么下载文件文件名太长就会被截取,但是用<a href="">就不会有文件名超长的问题?!
最新推荐文章于 2024-06-02 14:01:07 发布