controller
/**
* 文件下载
* @throws IOException
*/
@RequestMapping("downloadFile")
public void downloadData(Long id, HttpServletRequest request, HttpServletResponse response) throws IOException {
DataRadarFarStation dataRadarFarStation = dataRadarFarStationService.selectDataRadarFarStationById(id);
//要下载的文件名 从前台传来
String fileNameNeedDown = dataRadarFarStation.getFileName();
//这里的路径是要下载的文件所在路径
String realPath = dataRadarFarStation.getFilePath();
File file = null;
file = new File(realPath);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
String aFileName = null;
request.setCharacterEncoding("UTF-8");
String agent = request.getHeader("User-Agent").toUpperCase();
if ((agent.indexOf("MSIE") > 0)
|| ((agent.indexOf
以id为参数进行文件下载
最新推荐文章于 2022-11-14 10:39:32 发布