//根据用户的id,查询上级的信息
List<Map<String, Object>> list = mapper.findSuperiorById(userId);
if (list != null && list.size() > 0) {
//获取上级的设备id
System.out.println(list);
HashMap<String, Object> map = (HashMap<String, Object>) list.get(0);
System.out.println(map);
String superior = map.get("equipmentId").toString();
System.out.println(superior);
//获取上级的姓名
String name = map.get("NAME").toString();
System.out.println(name);
List<Map<String, Object>> list = mapper.findSuperiorById(userId);
if (list != null && list.size() > 0) {
//获取上级的设备id
System.out.println(list);
HashMap<String, Object> map = (HashMap<String, Object>) list.get(0);
System.out.println(map);
String superior = map.get("equipmentId").toString();
System.out.println(superior);
//获取上级的姓名
String name = map.get("NAME").toString();
System.out.println(name);
}
开始(String)强转报错
String superior = (String)map.get("equipmentId");
之后
String superior = map.get("equipmentId").toString();