1. 程式人生 > >問題:java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

問題:java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

使用帶有 '[]' 的引數請求介面時,返回如下錯誤

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

百度之後許多提示是:需要更改Tomcat的配置,可是對於Springboot工程,不知如何更改,經過多次嘗試,發現解決辦法如下:

  • 1、請求引數中取出類似 '[]' 的字元。
  • 2、對請求引數進行 UrlEncoder 編碼一下,就OK了(推薦)。