前台请求:
Request URL:http://localhost:8080/testweb/UserDefined/downloadFile?userName=lijing&localPath=e:\download&fileName=BcaApiX.jar
Request Method:GET
Status Code:400 Bad Request
后台异常:
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
原因:localPath=e:\download这里“\”的问题,\是路径分隔符
解决:
Request URL:http://localhost:8080/testweb/UserDefined/downloadFile?userName=lijing&localPath=e://download&fileName=BcaApiX.jar
Request Method:GET
Status Code:200 OK
本文介绍了一种常见的HTTP请求错误——因路径分隔符使用不当导致的400错误,并提供了解决方案。通过将请求URL中的文件路径从使用反斜杠()更改为正斜杠(/),成功解决了非法字符问题。

被折叠的 条评论
为什么被折叠?



