//下载模版
/* 文件下载 */
private String fileName;
private InputStream inputStream;
/**
* 下载附件 基于upload文件夹
* 页面调用方式示例
* url:upload下的文件路径
* <a href="$!link.contextPath/common/download_downloadAnnex.htm?url=userinfo/$!{userInfo.userId}/archives/$!{object.archivesPic}">
* @return
*/
public String downloadAnnex(){
try {
String msg="";
String url = request.getParameter("url");
if(StringUtils.isNotEmpty(url)){
String filePath = request.getSession().getServletContext().getRealPath(File.separator) + "module/"+url;
File file = new File(filePath);
if(file.exists() && !file.isDirectory()){
fileName = url.substring(url.lastIndexOf("/")+1);
inputStream = ServletActionContext.getServletContext().getResourceAsStream(File.separator + "module" + File.separator + url);
}else{
msg = "文件不存在";//跳转到消息提示页面
return "tip";
}
}
} catch (Exception e) {
request.setAttribute("msg","系统繁忙,请稍后再试。");
e.printStackTrace();
}
return "download";
}
下载excel模板
最新推荐文章于 2023-02-09 14:33:36 发布