第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Spring boot中下載文件名稱中文變___________下劃線了,請問如何處理?

Spring boot中下載文件名稱中文變___________下劃線了,請問如何處理?

泥巴先生 2018-03-23 16:56:35
@GetMapping("/download") @ResponseBody public?ResponseEntity?serveFile(@RequestParam?String?filename)?throws?IOException{ ????filename=new?String(filename.getBytes(),"utf-8");//有沒有這句話都不行 ????Resource?file=new?FileSystemResource("D:\\workspace\\idea_me\\demo\\upload-dir"+File.separator+?filename); ????HttpHeaders?headers?=?new?HttpHeaders(); ????headers.add("Cache-Control",?"no-cache,?no-store,?must-revalidate"); ????headers.add("Content-Disposition",?String.format("attachment;?filename=\"%s\"",?file.getFilename())); ????headers.add("Pragma",?"no-cache"); ????headers.add("Expires",?"0"); ????return?ResponseEntity ????????????.ok() ????????????.headers(headers) ????????????.contentLength(file.contentLength()) ????????????.contentType(MediaType.parseMediaType("application/octet-stream;charset=utf-8"))//這里也是都不行 ????????????.body(new?InputStreamResource(file.getInputStream())); }
查看完整描述

1 回答

已采納
?
HansonQ

TA貢獻223條經(jīng)驗 獲得超56個贊

//使得你上面的代碼具有以下作用
response.setHeader("Content-Disposition",?"attachment;filename="?+?URLEncoder.encode("壁紙.jpg",?"UTF-8"));?
response.setHeader("Context-Type",?"application/xmsdownload");


查看完整回答
1 反對 回復 2018-04-08
  • 1 回答
  • 0 關注
  • 7143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號