【发布时间】:2018-02-28 22:38:52
【问题描述】:
当我点击前端的按钮时,我想下载一个文件。
前端
<td><a name="${flow.name}" data-toggle="tooltip" title="Report" class="generateReport"><span class="far fa-file-excel"></span></a></td>
控制器
@RequestMapping(value = "/flow/generate-report" , method = RequestMethod.GET)
public @ResponseBody void generateFlowReport(@RequestParam("flowName") String flowName) {
TestFlow.generateReport(flowName);
}
类
public static void generateReport(String flowName) {
//code to generate the file
// Write the output to a file
FileOutputStream fileOut;
try {
new File(FILE_DIR).mkdirs();
fileOut = new FileOutputStream(FILE_PATH);
workbook.write(fileOut);
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
我现在如何将它传递给前端??
【问题讨论】:
-
编辑:如果有什么不同的话,它是一个 excel 文件。
标签: javascript java jquery html spring