记录一个数据分组的方法:
String groupCondition = "#";//"#"代表你查询实体类所对应数据库的属性名
List<Map> list = *Service.queryBy*();//根据某种条件查询处理的数据集
Map item;//声明供循环使用的对象
Map<String, List<Map>> result= new HashMap<String, List<Map>>(); // 声明最终得到的结果集
for(int i=0;i<list.size();i++){
item= list.get(i);
if(result.containsKey(item.get("groupCondition"))){
result.get(item.get("groupCondition")).add(item);
}else{
List<Map> tempList = new ArrayList<Map>();
tempList.add(item);
result.put(item.get("groupCondition"),tempList);
}
}