我使用 JAX-RS 和 Jersey。我有这样的方法。这对我不起作用。
@POST
public Response addOrder(List<Long> ids) {
...
}
当我使用 Postman 发送请求时,出现错误。
Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@6befd3c2; line: 1, column: 1]
我的要求:
{
"ids": [1, 2, 3]
}
有什么办法可以让它发挥作用吗?
最佳答案
您需要一个包含属性ids
的类
public class IdList {
private List<Long> ids;
// getter and setter
}
然后
@POST
public Response addOrder(IdList idList) {
}
关于java - 使用 jax-rs 和 jersey 获取长整型列表或数组作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32995295/