参考:https://blog.youkuaiyun.com/weixin_44561592/article/details/126385519
public void downloadFileIntoPath(HttpServletResponse response, String path, String fileName) [
OutputStream os;
try {
response.addHeader("Content-Disposition","attachment;filename=" + URLEncoder,encode(fileame,"UTF-8"));
response.setContentType("application/octet-stream");
byte[] bytes = FileUtil.readBytes(path + File.separator + fileName);
os = response.getOutputStream();
os.write(bytes);You,5 minutes ago 。 Uncommitted changes
os.flush() ;
os.close();
}catch (IOException e){
L0G.error("",e);
}
js
var $form = $("<form/>");
$form.attr("action", '../fileinfo/downloadfile');
$form.attr("method",POST");
$form.append('<input name="pwd" type="hidden" value="'+ en +'"/>');
$form.append('<input name="fileName" type="hidden" value="'+ fileName +'"/>');
S("body").append($form) ;
$form.submit().remove() :