一:利用超链接

<a href="/download/a.docx">download</a>

二:java代码

1.页面

<a href="/download">下载</a>

2.路径

public void configConstant(Constants me) {
me.setBaseUploadPath("upload");// 配置文件上传路径
me.setBaseDownloadPath("/download");//配置文件下载路径

}

3.代码

public void download() {
String path = getSession().getServletContext().getRealPath("download");
File file = new File(path + "/a.docx");
System.out.println(path);
System.out.println(file.exists());
if (file.exists()) {
renderFile(file);
} else {
renderJson("文件不存在");
}
}

4.结果

转自:http://blog.csdn.net/m0_37934074/article/details/78130412

最新文章

  1. 通过三次优化,我将gif加载优化了16.9%
  2. iOS 开发-- enum与typeof enum用法
  3. 大话ASP.NET(第二篇,Angular结构篇--翻译)
  4. Senparc.Weixin.MP.Sample 配置redis服务器密码
  5. 原创docker dcos 的安装
  6. 不能运行,:framework not found SenTestingKit
  7. magento去掉小数点后面的0
  8. 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串&quot;+100&quot;,&quot;5e2&quot;,&quot;-123&quot;,&quot;3.1416&quot;和&quot;-1E-16&quot;都表示数值。 但是&quot;12e&quot;,&quot;1a3.14&quot;,&quot;1.2.3&quot;,&quot;+-5&quot;和&quot;12e+4.3&quot;都不是。
  9. 拥抱ARM妹纸第二季 之 第一次 点亮太阳
  10. SRM 409(1-250pt, 1-500pt)
  11. linux如何开机以命令行形式启动?
  12. 如何修改Linux系统下的PATH(如何添加自己的路径到PATH)
  13. [翻译] C++ STL容器参考手册(第一章 &lt;array&gt;)
  14. 【main()的参数探究】
  15. No module named zope.interface error的解决
  16. VS Code &amp; MacOS &amp; Zsh
  17. Hdoj 2454.Degree Sequence of Graph G 题解
  18. Java Web之验证码
  19. 桌面应用开发之WPF页面导航
  20. 学习 Spring Boot:(二十九)Spring Boot Junit 单元测试

热门文章

  1. LK光流算法的三个假设
  2. 如何优雅使用Coursera ? —— Coursera 视频缓冲 &amp; 字幕遮挡
  3. java 对象
  4. Sass带来的变革_sass, scss 教程_w3cplus - Google Chrome
  5. Windows Azure中WebSite 网站, Cloud Service 云服务,Virtual Machine 虚拟机的比较
  6. Oracle EBS AP 已经完全付款的发票仍然可以选择并进行零金额的付款
  7. Ubuntu做Tomcat服务:insserv: warning: script &#39;tomcat&#39; missing LSB tags and overrides
  8. python下载指定的版本包
  9. 制作动态logo教程
  10. jenkins+gitlib+git+mysql5.6+sonarqube+sonarrunner