BOU*_*LID 3 java file-upload spring-boot
我想知道为什么 spring boot 将 MultiPartFile 文件名特殊字符转换为 ?(例如 \xc3\xa9\xc3\xa9\xc3\xa9.pdf 转换为 ???.pdf)。我需要配置 Spring 来禁用此行为吗?我已经检查了我的 jvm 配置中的 file.encoding,它已经设置为 UTF-8。
\n\n我这样执行文件上传:
\n\n@PostMapping("/upload")\npublic void uploadFile(@RequestParam MultipartFile file){\n// todo : ...\n}\nRun Code Online (Sandbox Code Playgroud)\n
你可以试试这个
String originalFileName = URLDecoder.decode(file.getOriginalFilename(), "UTF-8");
Run Code Online (Sandbox Code Playgroud)
希望对你有用
| 归档时间: |
|
| 查看次数: |
2320 次 |
| 最近记录: |