postman下载文件名不对
时间: 2023-12-04 07:42:03 浏览: 377
postman下载文件
根据提供的引用内容,问题出在设置文件名的代码上。可以尝试以下两种方法解决问题:
1. 修改设置文件名的代码,将`ContentDisposition`改为`Content-Disposition`,并将`filename`改为`filename*`,代码如下:
```java
String fileName = URLEncoder.encode("your file name", "UTF-8");
httpServletResponse.setContentType("application/octet-stream; charset=utf-8");
httpServletResponse.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName);
```
2. 将文件名直接写在URL中,不通过设置`Content-Disposition`来实现文件下载,代码如下:
```java
String fileName = URLEncoder.encode("your file name", "UTF-8");
String url = "your download url" + "?filename=" + fileName;
httpServletResponse.sendRedirect(url);
```
阅读全文