@RequestMapping(value = "/{meetingType}/download/{fileId}", method = RequestMethod.GET)
private void download(@PathVariable String meetingType,@PathVariable long fileId,HttpServletResponse response) throws Exception {
if(!SecurityUtils.getSubject().isPermitted(meetingType+"-"+PER_DELETE)){ return ;}
BufferedInputStream ips = null;
ServletOutputStream out = null;
try {
Material material = materialService.selectByPrimaryKey(fileId);
String url = Constans.FOLDER_CATALOG + material.getFileUrl();
String fileName = material.getName()+"."+material.getSuffixName();
fileName = URLEncoder.encode(fileName,"UTF-8"); //解决下载文件名乱码
File file = new File(url);
if(!file.exists()){
JSONObject json = new JSONObject();
json.put("state","该文件已不存在");
AjaxUtil.responseJson(json,response);
}
response.setCharacterEnco
javaWeb文件下载
最新推荐文章于 2023-04-18 10:54:18 发布