日期:2014-05-17 浏览次数:20867 次
$("#btnExport").click(function(event) {
$("#op").val("export");
$("#pageNo").val(1);
$("#frmQuery").submit();
$("#op").val("");
});
protected void exportFile(File file) {
logger.debug("file=" + file);
ServletOutputStream out = null;
try {
byte[] fileData = FileUtils.readFileToByteArray(file);
String filename = file.getName();
logger.debug("fileData.length=" + fileData.length);
HttpServletResponse response = ServletActionContext.getResponse();
response.addHeader("Content-Disposition", "attachment; filename="
+ filename);
response.addHeader("Content-Length", "" + file.length());
response.setContentType("application/octet-stream");
out = response.getOutputStream();
out.write(fileData);
} catch (Exception e) {
logger.error("输出文件时出错! " + file.getAbsolutePath(), e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
&nbs