5
此代码工作正常,如果我传递一个类(MyClass的)已经@XmlRoolElement如何传输的原始列表与新泽西+ JAXB + JSON
客户
WebResource webResource = restClient.resource(getRessourceURL());
return webResource.get(new GenericType<List<MyClass>>(){});
但如果我尝试转移原始,比如字符串,整数,布尔等..
客户
WebResource webResource = restClient.resource(getRessourceURL());
return webResource.get(new GenericType<List<Integer>>(){});
我收到错误:
不能编组型“java.lang.Integer中的”为元素,因为它缺少一个@XmlRootElement注释
我得到完全相同的结果发送实体参数,以我的请求时:
客户
WebResource webResource = restClient.resource(getRessourceURL());
return webResource.post(new GenericType<List<Integer>>(){}, Arrays.toList("1"));
服务器
@GET
@Path("/PATH")
@Produces(MediaType.APPLICATION_JSON)
public List<MyClass> getListOfMyClass(List<Integer> myClassIdList)
{
return getMyClassList(myClassIdList);
}
有没有办法来转院这种名单没有为这些基本类型创建一个包装类?还是我错过了明显的东西?