![](/img/trans.png)
[英]Send a map as request param to a GET request in Spring Boot app
[英]How can I send a String list as param with a lot of items in a get mapping request in Spring boot?
我有一个 Spring 启动 controller 使用获取请求方法作为 Rest ZDB9742CE38714CA8DE6FZA,A
第三个参数ids是一个字符串列表。 通常这不是问题,但有时这个列表需要超过六百个项目,并且由于 URI 的长度限制而引发错误。
@GetMapping("/mhcil/details")
public ResponseEntity findDetails(
@RequestParam(name = "from") String from,
@RequestParam(name = "to") String to,
@RequestParam(name = "cil", required = false) List<String> cils,
@RequestParam(name = "responsetype") ResponseType responseType,
@NotNull @RequestHeader(value = "Oauth") String token
我试图将所有参数移动到 class,但由于是GET
请求,它不能解决 URI 字符限制的问题。 我有补丁可以从@RequestParam
更改为@RequestBody
并使用POST
或PUT
请求而不是 get,但我更愿意通过维护GET
请求来解决它。
我已经开始考虑发送一个压缩字符串,然后在 controller 中解压缩它,但我不知道该怎么做。
任何人都可以向我提供有关如何继续解决它的提示吗?
提前致谢
您可以将server.max-http-header-size
默认设置从 8kB 更改为您需要的任何大小,但我建议改用POST
。 请参阅: https://stackoverflow.com/a/27950790/3684747
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.