【发布时间】:2020-03-20 15:59:53
【问题描述】:
我正在尝试获取与我的研究标准相对应的所有产品的列表值,在我的案例中,研究标准是使用 Postman (GET METHOD) 的参考和区域:
https://localhost/services/choices/?ref=test1&ref=test2®ion=west
但每当我尝试在我的代码中获取我的引用时,我都会收到一个大小为零的列表。
@Path("/choices")
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "get products")
@ApiResponses(value = {@ApiResponse(code=200,message = "Success"),
@ApiResponse(code=500, message = "Server error")
})
public Response getProduct(@QueryParam("ref") final List<String> ref,
@QueryParam("region") final String region,
@Context final HttpServletRequest request){
LOGGER.info("Call for references {} and region {}",ref,region);
try{
return Response.ok(productBusinessService.getProducts(ref,region)).build();
}catch (Exception e){
throw new InternalServerErrorHttpException("Technical Error", e.getMessage(), e);
}finally {
LOGGER.info("End of the Call for references {} and region {}",ref,region);
}
}
我的问题是:是否可以在邮递员中传递具有相同键名的多个查询参数,如果可以,为什么我在获取区域值时收到空列表
【问题讨论】:
-
如果您尝试使用 curl 访问 api 会发生什么?
-
我不认为这是邮递员的问题。我做了完全相同的服务,它的多参数工作
标签: java postman query-parameters queryparam