Redis獲取json中的值
阿新 • • 發佈:2018-12-25
@RequestMapping(value="/findAllAreaController") public void findAllAreaController(){ List<AreaVO> areaList = this.areaService.findAllAreaService(); Jedis jedis = new Jedis("localhost"); System.out.println("連線成功!!!"); //設定redis字串資料 for(int i=0;i<areaList.size();i++){ JSONObject json = new JSONObject(); json.put("id", areaList.get(i).getId()); json.put("area_name", areaList.get(i).getArea_name()); json.put("parent_id", areaList.get(i).getArea_Id()); jedis.set(areaList.get(i).getId().toString(), json.toJSONString()); String key = areaList.get(i).getId().toString(); //獲取儲存的資料並輸入 System.out.println("area_name:"+jedis.get(key)); } }