相关疑难解决方法(0)

尝试使用Jersey将JSON转换为POJO时出错

我这样做:

WebResource resource = client.resource(urlStr); 
resource.accept(MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE);
GenericType<List<EMailInformations>> genericType = new GenericType<List<EMailInformations>>() {};
List<EMailInformations> response = null; 
try{ 
    response = resource.get(genericType); 
} catch (UniformInterfaceException ue) { 
    ClientResponse clientResponse = ue.getResponse(); 
}
Run Code Online (Sandbox Code Playgroud)

类EMailInformations

@XmlRootElement
public class EMailInformations {
    private long id;

    public EMailInformations(){

    }

    public EMailInformations(long id) {
        super();
        this.id = id;
    }
        //getters & setters ...
}
Run Code Online (Sandbox Code Playgroud)

一些JSON响应

{"cn":[{"id":"302","l":"7","d":1308239209000,"rev":14667,"fileAsStr":"TAICHIMARO, Marouane","_attrs":{"lastName":"TAICHIMARO","imAddress1":"other:......
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

21 juin 2011 16:56:01 com.sun.jersey.api.client.ClientResponse getEntity
GRAVE: A message body reader for Java class java.util.List, and Java type java.util.List<fr.liberacces.pool.liferay.connecteur.modele.EMailInformations>, …
Run Code Online (Sandbox Code Playgroud)

java json jaxb jersey

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

jaxb ×1

jersey ×1

json ×1