<%@ page contentType="application/x-xls;charset=GBK"%>
<%@ page import="java.io.File,java.io.FileInputStream"%>
<%@ page import="javax.servlet.ServletOutputStream"%>
<%
out.clear();
out = pageContext.pushBody();
String fileName = request.getParameter("fileName");
response.setHeader("Content-disposition","inline;filename="+fileName);
File fileLoad = new File(request.getRealPath("")+"/shipment/template", fileName);
long fileLength = fileLoad.length();
String length = String.valueOf(fileLength);
response.setHeader("Content_Length", length);
FileInputStream input = null;
ServletOutputStream output = null;
try {
input = new FileInputStream(fileLoad);
output = response.getOutputStream();
byte[] block = new byte[1024];
int len = 0;
while ((len = input.read(block)) != -1) {
output.write(block, 0, len);
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
input.close();
output.flush();
output.close();
} catch (Exception ex) {
ex.getMessage();
}
}
%>
作者“ERDP技術架構”