//后台拼json格式,response写到前端:
Map<String,Map<String,Map<String,String>>> codeMap = new HashMap<String,Map<String,Map<String,String>>>();
Map<String,Map<String,String>> tempDSCodeMap = new HashMap<String, Map<String,String>>();
List<SMCSCodeDTO> codeDTOs = smcsCodeDAO.findAll();
for(int i=0; i<codeDTOs.size(); i++){
@SuppressWarnings("rawtypes")
SMCSCodeDTO obj = (SMCSCodeDTO)codeDTOs.get(i);
String codeName = (String)obj.get("AAA100");
Map<String,String> item = tempDSCodeMap.get(codeName);
if(item == null){
item = new HashMap<String,String>();
tempDSCodeMap.put(codeName, item);
}
item.put(obj.get("AAA102").toString(), obj.get("AAA103").toString());
}
codeMap.put("data", tempDSCodeMap);
//首次进入二级代码
//item:{}
//tempDSCodeMap:{AKA070={}}
//item:{100400=含漱液}
//tempDSCodeMap:{AKA070={100400=含漱液}}
//第二次
//item {100500=胶浆剂(外用)}
//tempDSCodeMap:{100500=胶浆剂(外用), 100400=含漱液}
前端页面
var cachecode={"data": {
"AKA075": {
"1": "明细扣款",
"2": "整体扣款"
},
"AKA177": {
"0": "否",
"1": "是"
},
"AKA176": {
"0": "否",
"1": "是"
}
}
}
localStorage.setItem("cachecode",JSON.stringify(cachecode));
取值
取值时需转化为json