我正在尝试将String
值加载到List
的{{1}}中,以下是示例代码
Integers
当我运行上面的代码时,我正在关注import java.util.List;
public class Test2 {
private List<Integer> list;
public List<Integer> getList() {
return list;
}
public void setList(List<Integer> list) {
this.list = list;
}
}
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Test {
public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
ObjectMapper objectMapper = new ObjectMapper();
String s = "1 2 3";
//colorFrameAlertConfig.setColorNumber(objectMapper.readValue(configEntry.getValue(), List.class));
Test2 t = new Test2();
t.setList(objectMapper.readValue(s, List.class)); //getting exception here
for(int i : t.getList()){
System.out.println(i);
}
}
}
exception