postman中请求springboot,返回excel文件的一些问题,请朋友们帮助解答一下。

postman中请求后台的导出文件接口,该接口的目的是返回下载一个Excel文件;(现在下载的Excel文件中内容什么都正常)
问题1:每一次在postman中请求下载,生成的文件名就是我在后台设置的中文名经过URLEncoder.encode(fileName,'UTF-8')编码后的值比如(**%E8%E87%AA%E6%9C)**等,为啥为什么不能正常显示我所设置的中文名,反而.xlsl后缀正常;
问题2:如果是直接send,则返回的数据在postman中显示是一堆乱码,这是否正常?
问题3:后台不管是send方式还是send+download方式,后台都会报错:No converter for [com.abc.ExcelDto] with preset Content-Type 'application/vnd.ms-excel;charset=UTF-8',我查找了解决方法,说是return 返回空即可,我也试了,确实可以解决,但是,我必须给前台返回一些提示信息,所以,这方法感觉不符合我现在的要求,我需不需要去过分在意这个错误。

1.使用UrlEncoder编码后,需要进行解码才能正常显示,这个解码是浏览器行为,使用浏览器访问时会正常显示。用postman时,没有进行解码,所以下载的文件名是编码过后的(**%E8%E87%AA%E6%9C)。
2.是正常的。文件下载时返回的是字节流。使用send方式直接将流显示,就看起来是一堆乱码样的。所以使用postman进行文件下载时需要使用send and download
3.文件下载一般返回void就行了。前端点击文件下载后,就会进行文件下载(直接下载或者弹出选择文件夹)。要看你需要返回什么信息了,不知道可不可以放到请求头

因为你的文件命中有CJKV(Chinese-Japanese-Korean-Vietnamese)字符,所以你后端的response header要使用


Content-Disposition: attachment; filename*=UTF-8'' <URLEncoder.encode(fileName,'UTF-8')>

这样的形式,否则返回后浏览器或者Postman会出现乱码


Content-Disposition - HTTP | MDN In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition