/**
* 下载作业层岗位模版文件
*
* @return
* @throws Exception
*/
public String downloadTemplateFile() throws Exception {
// 获取相对路径 execle文件的web目录如:/jx/enshi/templates
String absolutePath = EnshiConstants.TEMPLATES_PATH_CONSTANTS;
// 获取真实路径
String realPath = ServletActionContext.getServletContext().getRealPath(
absolutePath);
// 文件名
String fileName = EnshiConstants.GWYD_ZYCJXDF_TEMPLATE_FILENAME;
InputStream input = new FileInputStream(realPath + File.separator
+ fileName);
int nSize = input.available();
byte[] byteArray = new byte[nSize];
input.read(byteArray);
input.close();
fileName = new String(fileName.getBytes("GBK"), "iso8859-1");
this.getResponse().reset();
this.getResponse().setContentType("application/vnd.ms-excel");
this.getResponse().setHeader("Content-disposition",
"attachment; filename=" + fileName);
OutputStream outFile = getResponse().getOutputStream();
outFile.write(byteArray);
outFile.flush();
outFile.close();
return null;
}
webwork 文件下载
最新推荐文章于 2023-03-23 11:18:07 发布