java.lang.IllegalArgumentException:
Invalid character found in the request target.
The valid characters are defined in RFC 7230 and RFC 3986
This
I encountered the same error when sending location of a file in a AJAX GET request.
Error:
java.lang.IllegalArgumentException:
Invalid character found in the request target.
The valid characters are defined in RFC 7230 and RFC 3986
Since the location had characters which are not recognized. I.e. "C:///" etc, the error was thrown.
The use of encodeURIComponent
helped me fix the issue since it encodes the component.
When you pass the Chinese characters make sure you add those inside "encodeURIComponent
" method. In my case:
$.ajax({
type: "GET",
url: 'removeFile?removeFileName=' + encodeURIComponent("C:///YO/Ed/PO/")
data: {},
dataType: 'json',