InvalidPathException: Malformed input or input contains unmappable characters 中文名文件 linux存儲失敗
使用java.nio.file.Path規(guī)范并解析路徑,生成文件到本地,部分文件名帶中文。提供對外下載文件接口,用于下載這些文件,下載后的文件要顯示中文名。本地(windows)開發(fā)調(diào)試都OK。通過docker容器部署到開發(fā)環(huán)境(linux集群)后,調(diào)用文件生成接口,后臺報錯,報錯信息如下:
java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: ????98?5??????????.doc
at sun.nio.fs.UnixPath.encode(UnixPath.java:147)
at sun.nio.fs.UnixPath.<init>(UnixPath.java:71)
at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281)
at java.io.File.toPath(File.java:2273)
at org.springframework.core.io.FileSystemResource.<init>(FileSystemResource.java:103)
at com.sx.system.controller.FileController.uploadFile$original$nBURC4QV(FileController.java:80)
at com.sx.system.controller.FileController.uploadFile$original$nBURC4QV$accessor$6dFBGKAE(FileController.java)
at com.sx.system.controller.FileController$auxiliary$hKLUE52q.call(Unknown Source)
at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)
at com.sx.system.controller.FileController.uploadFile(FileController.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
解決辦法 通過設置java環(huán)境參數(shù)來解決,若是docker部署的,有KubeSphere,則編輯yaml文件 添加即可文章來源:http://www.zghlxwxcb.cn/news/detail-612551.html
JAVA_TOOL_OPTIONS=‘-Dfile.encoding=“UTF-8” -Dsun.jnu.encoding=“UTF-8”’文章來源地址http://www.zghlxwxcb.cn/news/detail-612551.html
到了這里,關(guān)于InvalidPathException: Malformed input or input contains unmappable characters 中文名文件 linux存儲失敗的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!