[英]How can I send a String list as param with a lot of items in a get mapping request in Spring boot?
I have a Spring boot controller with a get request method to be used as Rest API, this one.我有一个 Spring 启动 controller 使用获取请求方法作为 Rest ZDB9742CE38714CA8DE6FZA,A
The third param, ids , is a String list.第三个参数ids是一个字符串列表。 Usually it is not a problem, but sometimes this list needs to have more than a six hundreds of items, and it launch an error because length limit on the URI.通常这不是问题,但有时这个列表需要超过六百个项目,并且由于 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
I tried to move all the parameters to a class, but since is a GET
request it doesn't solve the issue with the URI characters limit.我试图将所有参数移动到 class,但由于是GET
请求,它不能解决 URI 字符限制的问题。 I have the patch to change from @RequestParam
to a @RequestBody
and use a POST
or PUT
request instead of get, but I will prefer to solve it maintaining the GET
request.我有补丁可以从@RequestParam
更改为@RequestBody
并使用POST
或PUT
请求而不是 get,但我更愿意通过维护GET
请求来解决它。
I have started thinking of sending a compressed String and then uncompress it in the controller, but I'm not sure about how to do it.我已经开始考虑发送一个压缩字符串,然后在 controller 中解压缩它,但我不知道该怎么做。
Can anyone provide me a hint about how can I proceed to solve it?任何人都可以向我提供有关如何继续解决它的提示吗?
Thanks in advance提前致谢
You could change the server.max-http-header-size
default setting from 8kB to whatever size you need, but i would recommend using POST
instead.您可以将server.max-http-header-size
默认设置从 8kB 更改为您需要的任何大小,但我建议改用POST
。 See: https://stackoverflow.com/a/27950790/3684747请参阅: https://stackoverflow.com/a/27950790/3684747
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.