源代码:service实现类:
String select_sql = "select cguid,(case isrz when 1 then 'PASS' when 0 then 'FAIL' end) as smrzzt from t_jb_user where mobile=?";
List<Map<String,Object>> list = ydbsDaoI.findList(select_sql, new Object[]{phoneno});//将查询得到的结果取出
String cguid = list.get(0).get("cguid")==null?"":list.get(0).get("cguid").toString();
String smrzzt = list.get(0).get("smrzzt")==null?"":list.get(0).get("smrzzt").toString();
因为没有对取出的结果加判断是否为空,直接取出,所以报错 index:0,size:0
加上if判断后便能正常运行:
String select_sql = "select cguid,(case isrz when 1 then 'PASS' when 0 then 'FAIL' end) as smrzzt from t_jb_user where mobile=?"; List<Map<String,Object>> list = ydbsDaoI.findList(select_sql, new Object[]{phoneno});
if(list != null && list.size() > 0){
//将查询得到的结果取出 String cguid = list.get(0).get("cguid")==null?"":list.get(0).get("cguid").toString(); String smrzzt = list.get(0).get("smrzzt")==null?"":list.get(0).get("smrzzt").toString();
} else {
return;
}