如何在REST API中的单个Queryparameter中实现多个值?
例如: http://主机:port/port/template/products/?productid = 1234,1235 如何实现上述URL的REST API,其中单个Queryparam通过多个值并获取Productids的所有现有记录
eg:
http://host:port/template/products/?productid=1234,1235
how to implement rest api for the above url where in single queryparam passing multiple values and get the all existing records for the productids
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试下面的事情来完成您要尝试的事情:
注意
逗号分隔的产品ID列表被复制到ProductIdlist列表对象中。您可以迭代列表,也可以将其发送到负责从数据源中获取结果的方法,例如数据库,
请注意,上面的代码shippet将响应返回为字符串。但是您也可以使API也以其他格式返回响应,例如JSON。
Try something like below to accomplish what you are trying to do:
Notice the
The comma separated list of product IDs are copied into the productIdList list object. You can either iterate through the list or send it over to the method that is responsible for fetching the results from the datasource, such as your database
Please note that the above code snippet returns the response as String. But you could make your API return a response in other formats too, such as JSON.