Invalid character found in the request target [/api/hsFile/download?filePath=E:\\%E4%B8%B4%E6%97%B6%E6%96%87%E4%BB%B6&fileName=aaaaa.xlsx]. The valid characters are defined in RFC 7230 and RFC 3986

发布时间 2023-06-25 11:19:50作者: 信铁寒胜

java.lang.IllegalArgumentException: Invalid character found in the request target [/api/hsFile/download?filePath=E:\\%E4%B8%B4%E6%97%B6%E6%96%87%E4%BB%B6&fileName=N230508A0002.xlsx]. The valid characters are defined in RFC 7230 and RFC 3986

1、原因:

/api/hsFile/download?filePath=E:\\%E4%B8%B4%E6%97%B6%E6%96%87%E4%BB%B6&fileName=N230508A0002.xlsx

url 的%E4%B8%B4%E6%97%B6%E6%96%87%E4%BB%B6 这段字符有问题

这种情况一般是把中文直接放到url上面导致的。

 

2、解决办法:

在传输前就要进行转义。