一:利用超链接

 <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.结果

  JFinal文件下载及设置路径

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

相关文章:

  • 2021-10-24
  • 2021-12-09
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2021-09-25
猜你喜欢
  • 2021-11-06
  • 2022-01-02
  • 2021-10-31
  • 2021-12-14
  • 2021-07-18
  • 2021-08-25
  • 2021-09-21
相关资源
相似解决方案