当一个参数的值被解码为字符串的 JSON 值时,我在 WebClient 编码查询参数时遇到问题。
\nqueryParams 值之一是:
\n[ { "var": "report_days", "op": "=", "val": "7" } ]\nRun Code Online (Sandbox Code Playgroud)\n它是从 HTTP 方法解码的: ? filter=%5B%7B%22var%22%3A%22report_days%22%2C%22op%22%3A%22%3D%22%2C%22val%22%3A%227%22%7D%5D.\n因此解码到MultiMap<String, String>正确执行,但在uriBuilder抛出异常。
[ { "var": "report_days", "op": "=", "val": "7" } ]\nRun Code Online (Sandbox Code Playgroud)\n例外:
\njava.lang.IllegalArgumentException: Not enough variable values available to expand \'"var"\'\n2021-11-22T11:17:38.252421700Z at org.springframework.web.util.UriComponents$VarArgsTemplateVariables.getValue(UriComponents.java:370)\n2021-11-22T11:17:38.252461800Z Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: \n2021-11-22T11:17:38.252492300Z Error has been observed at the following site(s):\n2021-11-22T11:17:38.252521200Z *__checkpoint \xc3\xa2\xe2\x80\xa1\xc2\xa2 org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]\n2021-11-22T11:17:38.252586100Z *__checkpoint \xc3\xa2\xe2\x80\xa1\xc2\xa2 HTTP GET "/nodeNew/all/last_protected?filter=%5B%7B%22var%22%3A%22report_days%22%2C%22op%22%3A%22%3D%22%2C%22val%22%3A%227%22%7D%5D" [ExceptionHandlingWebHandler]\n2021-11-22T11:17:38.252628200Z Stack trace:\n2021-11-22T11:17:38.252666300Z at …Run Code Online (Sandbox Code Playgroud)