如何訪問Map <String, Object>
類型的地圖內的列表?如何訪問地圖中的列表並通過該列表循環
public Map<String, Object> getListInsideMapObject(Long id, Date from) {
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> mapList = new ArrayList<>();
List<MappedList> conTime = new ArrayList<>();
conTime = xxxRepository.findByxxx(id, from);
Map<String, Object> map = xxxService.xxx(id);
List<String> times = (List<String>) map.get("xxx");
for (MappedList t : conTime) {
int num = 0;
Map<String, Object> res = new HashMap<>();
res.put("x", "");
res.put("status", null);
for (Contraction c : con) {
num++;
res.put("status", "stat");
res.put("x", new Date());
}
}
res.put("y", num);
mapList.add(res);
result.put("mapList", mapList);
result.put("mapListA", mapListA);
result.put("mapListB", mapListB);
//etc
return result;
}
我想調用這個服務(getListInsideMapObject
),並從該圖和遍歷每個列表訪問每個列表。例如在課堂XXX我想打電話給getListInsideMapObject(長ID,從日期)作爲一種服務,並從地圖訪問各列表
你可以發表[MCVE],以減少該代碼的複雜性。從我看到的,你只是有一個'名單
你似乎已經有代碼,試圖做你在問什麼。它不起作用嗎?如果不是,你會得到什麼錯誤,或者預期與實際產出是什麼?無論您的代碼是否試圖按照您的要求去做,您是否可以更清楚地發佈[mcve]來證明您遇到的問題? – Dukeling
w是什麼,弱是什麼。爲什麼你的方法叫做'getListInsideMapObject',但實際上是建立一個地圖?你應該更清楚。 –