1. 程式人生 > >mybatis查詢結果為Map型別

mybatis查詢結果為Map型別

1.mapper.xml

<select id="findYwmsid" resultType="java.util.Map">
        select DISTINCT(yid) AS "yid",sd.label AS "name" 
        from qk_yw_ywms 
    </select>

2.Dao

List<Map<String,String>> findYid();

3.controller

List<Map<String,String>> lst = qkYService.findYid();
model.addAttribute("yMap"
, lst);

4.jsp

<c:forEach items="${yMap }" var="map">
    <form:option value="${map.yid }" label="${map.name }" />                
</c:forEach>