my sqlmap.xml
<select id="getList" resultType="hashmap">
SELECT A,B,C,D FROM MYTABLE
</select>
result example
A B C D
john 123 math 100
jade 456 math 78
janet 789 math 98
controller code
@RequestMapping("/my/result.json")
public @ResponseBody List MyResult(){
return myDAO.getList();
}
but, json result is looking confused column sort such as,
[
{"B":123,"C":"math","A":"john","D":100},
{"B":456,"C":"math","A":"jade","D":78},
{"B":789,"C":"math","A":"janet","D":98}
]
I want get result with sql with defined Column names and index. but in result, it's different column name index between sql and hashmap. Any idea how to get json result same as sql result?
To solve this issue, in sqlmap, just set the resultType
to java.util.LinkedHashMap
:
<select id="getList" resultType="java.util.LinkedHashMap">
SELECT A,B,C,D FROM MYTABLE
</select>
I have the same issue. I have set the resultType ="java.util.LinkedHashMap" already. But the list returned still out of order. Why?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.