for (int i = 0; i < data.size(); i++) {
//取出查询的每一条数据 list 中每一条都是hashmap
HashMap<String, Object> hashMap = (HashMap<String, Object>) data.get(i);
String picture = (String) hashMap.get("picture");
System.out.println(picture+"----------------------");
List<String> pictureC = new ArrayList<>();
if (picture.length()>0) {
String[] split = picture.split(",");
for (int t = 0; t < split.length; t++) {
pictureC.add(split[t]);
}
}
String video = (String) hashMap.get("video");
List<String> videoC = new ArrayList<>();
if (video.length()>0) {
String[] split = video.split(",");
for (int t = 0; t < split.length; t++) {
videoC.add(split[t]);
}
}
如果数据库没有 picture, video 图片和视频的话,上面if()会报错,空指针异常
给他俩加上 picture!=null && 就可以,判断一下
for (int i = 0; i < data.size(); i++) {
//取出查询的每一条数据 list 中每一条都是hashmap
HashMap<String, Object> hashMap = (HashMap<String, Object>) data.get(i);
String picture = (String) hashMap.get("picture");
System.out.println(picture+"----------------------");
List<String> pictureC = new ArrayList<>();
if (picture!=null &&picture.length()>0) {
String[] split = picture.split(",");
for (int t = 0; t < split.length; t++) {
pictureC.add(split[t]);
}
}
String video = (String) hashMap.get("video");
List<String> videoC = new ArrayList<>();
if (picture!=null &&video.length()>0) {
String[] split = video.split(",");
for (int t = 0; t < split.length; t++) {
videoC.add(split[t]);
}
}