小编kam*_*uti的帖子

WebClient编码queryParams spring

当一个参数的值被解码为字符串的 JSON 值时,我在 WebClient 编码查询参数时遇到问题。

\n

queryParams 值之一是:

\n
[ { "var": "report_days", "op": "=", "val": "7" } ]\n
Run 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抛出异常。

\n
[ { "var": "report_days", "op": "=", "val": "7" } ]\n
Run Code Online (Sandbox Code Playgroud)\n

例外:

\n
java.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)

spring spring-mvc spring-boot spring-webflux

3
推荐指数
1
解决办法
5941
查看次数

标签 统计

spring ×1

spring-boot ×1

spring-mvc ×1

spring-webflux ×1