简体   繁体   English

如何在 Spring 启动中的获取映射请求中发送一个字符串列表作为参数,其中包含很多项目?

[英]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并使用POSTPUT请求而不是 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.

相关问题 将 map 作为请求参数发送到 Spring 启动应用程序中的 GET 请求 - Send a map as request param to a GET request in Spring Boot app 如何在对Spring Boot Controller的GET请求中接受LocalDateTime参数? - How to accept LocalDateTime param in a GET request to Spring Boot Controller? 如何在 Spring Boot 中获取添加订单的选定项目? - How can I get the selected items for adding an order in Spring Boot? 如何通过GET请求将对象发送到Spring? - How can I send objects to Spring by GET request? 如何在Spring Boot中指定回退请求映射 - How to specify a fallback request mapping in Spring Boot 如何在页面呈现后从 th:each 获取项目的值,以便将其作为请求参数发送(不使用 js)? - How can I get a value of an item from th:each after the page is rendered in order to send it as a request param (without using js)? 如何使用 Postman 在 Spring Boot 的请求参数中传递时间戳、日期 - How to pass Timestamp,date in request param in spring boot using Postman 如何在spring boot中捕获客户端参数错误的“请求处理失败”? - How to catch `Request processing failed` for client param error in spring boot? 我可以在 Spring Boot 中使用请求正文执行 GET 吗? - Can I do a GET with request body in Spring Boot? 如果请求映射方法返回列表,Spring Boot如何解析视图名称? - How does spring boot resolve view names if the request mapping method returns a list?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM