简体   繁体   中英

How to get list of all query params passed in url in RestTemplate springBoot application?

Working on a springboot based rest service using RestTemplate. When query param is of limited number then it makes sense to define them as method parameters but I have a use case where a user can query for more than 1000 params. Obviously I cann't make 1000 params method so how do I get all the query params - something which achievable from HttpRequest object but isn't exposed here via springboot based controller method as far as I know. So what should be done in this case?

For example if there's just one query param say query1 then below method will do desired work. What if I have 1000+ such query params?

@RequestMapping(value = "urlPath", method = RequestMethod.GET)
    public ResponseEntity<?> method1(**@RequestParam("query1") Optional<String> fieldsOptional**)
    {
//do stuff
}

您可以简单地将@RequestParam Map<String, String> params到您的方法中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM