JFinal文件下载及设置路径
2024-08-26 23:51:23
一:利用超链接
<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
最新文章
- 通过三次优化,我将gif加载优化了16.9%
- iOS 开发-- enum与typeof enum用法
- 大话ASP.NET(第二篇,Angular结构篇--翻译)
- Senparc.Weixin.MP.Sample 配置redis服务器密码
- 原创docker dcos 的安装
- 不能运行,:framework not found SenTestingKit
- magento去掉小数点后面的0
- 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串";+100";,";5e2";,";-123";,";3.1416";和";-1E-16";都表示数值。 但是";12e";,";1a3.14";,";1.2.3";,";+-5";和";12e+4.3";都不是。
- 拥抱ARM妹纸第二季 之 第一次 点亮太阳
- SRM 409(1-250pt, 1-500pt)
- linux如何开机以命令行形式启动?
- 如何修改Linux系统下的PATH(如何添加自己的路径到PATH)
- [翻译] C++ STL容器参考手册(第一章 <;array>;)
- 【main()的参数探究】
- No module named zope.interface error的解决
- VS Code &; MacOS &; Zsh
- Hdoj 2454.Degree Sequence of Graph G 题解
- Java Web之验证码
- 桌面应用开发之WPF页面导航
- 学习 Spring Boot:(二十九)Spring Boot Junit 单元测试
热门文章
- LK光流算法的三个假设
- 如何优雅使用Coursera ? —— Coursera 视频缓冲 &; 字幕遮挡
- java 对象
- Sass带来的变革_sass, scss 教程_w3cplus - Google Chrome
- Windows Azure中WebSite 网站, Cloud Service 云服务,Virtual Machine 虚拟机的比较
- Oracle EBS AP 已经完全付款的发票仍然可以选择并进行零金额的付款
- Ubuntu做Tomcat服务:insserv: warning: script &#39;tomcat&#39; missing LSB tags and overrides
- python下载指定的版本包
- 制作动态logo教程
- jenkins+gitlib+git+mysql5.6+sonarqube+sonarrunner