喜的朋友我在阿賈克斯方法,像這樣的java.util.Map
對象..解析的JSONObject在JavaScript或jQuery的
Map<String,List<String>> sm = new TreeMap<>();
List<String> str = new ArrayList<String>();
str.add("val1");
str.add("val2");
str.add("val3");
str.add("val4");
sm.put("shift1", str);
sm.put("shift2", str);
sm.put("shift3", str);
sm.put("shift4", str);
JSONObject json = new JSONObject(sm);
response.getWriter().print(json);
在運行時,地圖要素將根據地圖元素我不得不產生表中增加或減少
這是Ajax調用..我不知道如何解析該Map對象並在javascript中動態生成表格。
請告訴我如何。
這是甚至編譯代碼?你怎麼能將一個java類型傳遞給'JSONObject'構造函數? – 2013-02-19 09:55:27
另一件事 - 每個'put'調用都會覆蓋之前的任務。這是你正在使用的實際代碼? – 2013-02-19 10:04:44
雅100%它會編譯..'JSONObject'是Java類.. – Clarence 2013-02-19 10:06:34