我試圖從數(shù)據(jù)庫獲取返回值,但它返回[]而不是數(shù)據(jù)JAVA 寧靜 @RequestMapping("/regLocal") public List<Map<String, Object>> regist_local(@RequestBody Map<String, Object> params){ Map<String, String> map = new HashMap<String, String>(); String location = (String) params.get("location_name"); // 'country' String code = (String) params.get("location_code"); // '1' map.put("location", location); map.put("code", code); List<Map<String, Object>> lists = se.selectList(ns+".regLocal", map); // it return [] return lists;}我的鞋<select id="regLocal" resultType="map"> select hll.hll_code hll_code, hll.hll_name hll_name from hl_local hll, h_location hl where hll.hl_location = #{code} and hl.hl_name = #{location}</select>在 Oracle DB SQL select 中工作正常,沒有任何問題。但它一直返回這個[]有人知道問題嗎?
1 回答

子衿沉夜
TA貢獻1828條經(jīng)驗 獲得超3個贊
您正在使用selectList
api并且XML聲明返回類型是map,但是您沒有指定查詢結(jié)果必須如何填充map。如果您希望數(shù)據(jù)庫中的每一行都映射到 a,Map<String, Object>
則必須編寫一個 ResultHandler。
您可以使用selectMap
api,但結(jié)果是一個Map<String,AnObject>
,其中 AnObject 是表示查詢中選擇的列的類。
添加回答
舉報
0/150
提交
取消