返回值以map承装
将mapper返回的数据变成map键值对
<select id="getMapList" resultType="Map">
select id,name from data_table;
</select>
@Mapper
public interface Mapper{
@MapKey("id")
Map<Object,Object> getMapList();
}
{"140800":{"name":"运城市","id":140800}}
"dataMap":{"140800":{"name":"运城市","id":140800}}
mybatis返回map,key为指定属性,value为实体类结果集
MyBatis返回Map键值对数据
List<Map<String, String>> getDataList();
sql:
<select id="getDataList" resultType="java.util.HashMap">
select code,`name` from jk_control_measure
</select>
结果:
[
{"NAME":"地面冲洗","name":"地面冲洗","code":"one","CODE":"one"},
{"NAME":"边界围挡","name":"边界围挡","code":"two","CODE":"two"},
{"NAME":"垃圾覆盖","name":"垃圾覆盖","code":"three","CODE":"three"},
{"NAME":"裸地覆盖","name":"裸地覆盖","code":"four","CODE":"four"},
{"NAME":"洒水降尘","name":"洒水降尘","code":"five","CODE":"five"},
{"NAME":"车辆冲洗","name":"车辆冲洗","code":"six","CODE":"six"},
{"NAME":"建筑渣土","name":"建筑渣土","code":"seven","CODE":"seven"},
{"NAME":"车辆冒装","name":"车辆冒装","code":"eight","CODE":"eight"},
{"NAME":"扬尘覆盖","name":"扬尘覆盖","code":"nine","CODE":"nine"},
{"NAME":"车辆撒漏","name":"车辆撒漏","code":"ten","CODE":"ten"},
{"NAME":"车辆黑烟","name":"车辆黑烟","code":"eleven","CODE":"eleven"},
{"NAME":"道路积尘","name":"道路积尘","code":"twelve","CODE":"twelve"}
]