spring jdbcTemplate查询值的转化问题
后台
public String getWhouseCodes(Integer whouseid) throws Exception {
StringBuffer sql = new StringBuffer();
sql.append("select distinct whousecode from tbl_wzgl_whouse where whouseid ="+whouseid);
List list = (List)this.jdbcTemplate.queryForList(sql.toString());
String whousecode=list.get(0).toString();
return whousecode;
}
前台
function callBackWhouseInfo(obj){
var data=JSON.parse(obj);
whousecode = json[0].WHOUSECODE;
}
返回的whousecode的值为"{WHOUSECODE=b1}"
问题 怎样把这返回值转换一下 得到的值为“b1”?? 我在前台这样转换时 var data=JSON.parse(obj); 有问题,报语法错误。请问各位大侠 有什么高招么,请不要吝啬赐教哈,小弟在此谢过了·····
------解决方案--------------------
Java code
JSONArray jsonArray = JSONArray.fromObject(actPkStr);
// Map map = new HashMap();
Collection<Map> jsonCollection = JSONArray.toCollection(jsonArray,
Map.class);
for (Map m : jsonCollection) {
String WHOUSECODE=m.get("WHOUSECODE");
}
------解决方案--------------------
actPkStr换成whousecode
------解决方案--------------------
不行就在后台呗,用Map转