Spring MultiPartFile,fileName中包含特殊字符

时间:2015-03-13 10:10:44

标签: java spring spring-mvc file-upload encoding

我拥有两个名为18''filtered.csv和Who's Driving.ppt的文件,需要使用Springs MultiPartFile上传。以下是处理此问题的REST URL。

@Transactional(readOnly = false)
@RequestMapping(value = "/v1/content/_upload",
        method = RequestMethod.POST,
        produces = {"application/json"})
@ResponseBody
public Content postUploadContent(@RequestParam("filename") MultipartFile file,
                                 @RequestParam(value = "contentHost", required = false) String contentHost,
                                 @RequestParam(value = "platform") String platform,
                                 @RequestParam(value = "artifactTypeKey") String artifactTypeKey,
                                 @RequestParam(value = "contentFamilyKey", required = false) String contentFamilyKey,
                                 @PathVariable(value = "nodeCode") String nodeCode) {

当我在Tomcat中部署应用程序并尝试使用此REST URL上传文件时,我收到500内部服务器错误。

方法 file.getOriginalFilename()导致此错误,因为此方法无法处理文件名中的特殊字符。

尝试使用无效的fileName上的UTF-8编码。

请帮助如何获取与上传的完全相同的特殊字符的文件名?

0 个答案:

没有答案
相关问题