0

On both sides I have:

Class ListWrapper {
    public List<String> l;
    ListWrapper(List<String> l) {
        this.l = l;
    }
}

On the client side I have:

    ObjectMapper mapper = new ObjectMapper();
String fl;
    try {
        fl = mapper.writeValueAsString(new ListWrapper(u.getList()));
    } catch (IOException e) {
        fl = "null";
    }

On the server side I have:

String data = getQuery().........;
List l = new ObjectMapper.readValue(data,ListWrapper.class).list;

Yet I'm getting:

org.codehaus.jackson.map.JsonMappingException: Can not create Bean deserializer for ([simple type, class il.ac.technion.ssdl.hitch.resource.ListWrapper]): neither default/delegating constructor nor factory methods found

When I'm trying to deserialize the list.

EDIT:

When printing the list on the client side I'm getting:

 {"list":["v1","v2,"v3"]}
4

1 回答 1

1

找到默认/委托构造函数或工厂方法

可能您的ListWrapper类缺少默认构造函数。

public ListWrapper(){
}

您的 JSON 字符串不正确:

{"list":["v1","v2,"v3"]} <<<--- v2 后缺少双引号!

于 2013-06-15T15:45:02.047 回答