admin管理员组

文章数量:1608813

解决springboot项目请求出现非法字符问题 java.lang.IllegalArgumentException:

Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

原因:上传文件名含中文,返回远程路径地址中带有中文,在使用XWPFTTempl等插件时获取文件时报错,需要转码才能使用。

可以使用hutool工具里面的---URLUtil.encode("url");

该方法只对文件名称进行编码,文件名前面的路径保持不变。

http://.../profile/upload/2023/04/10/张三.jpeg

==》http://.../profile/upload/2023/04/10/%5cxe5bca0%5cxe4b889.jpeg

本文标签: requestparsingoccurrenceshttpDebug