锘??xml version="1.0" encoding="utf-8" standalone="yes"?>色爱av综合网,а√在线中文在线新版,aa视频在线观看http://www.aygfsteel.com/Vanilla-Sky/category/46590.html閫愭ⅵ涔嬫梾zh-cnTue, 12 Oct 2010 11:50:16 GMTTue, 12 Oct 2010 11:50:16 GMT60- 涓涓猨Query 鍜宩son 欏甸潰浜や簰鐨勫疄渚?/title>http://www.aygfsteel.com/Vanilla-Sky/archive/2010/10/12/334679.html鏃犲敖嫻?/dc:creator>鏃犲敖嫻?/author>Tue, 12 Oct 2010 09:27:00 GMThttp://www.aygfsteel.com/Vanilla-Sky/archive/2010/10/12/334679.htmlhttp://www.aygfsteel.com/Vanilla-Sky/comments/334679.htmlhttp://www.aygfsteel.com/Vanilla-Sky/archive/2010/10/12/334679.html#Feedback0http://www.aygfsteel.com/Vanilla-Sky/comments/commentRss/334679.htmlhttp://www.aygfsteel.com/Vanilla-Sky/services/trackbacks/334679.html宸ヤ綔涓殑鐐規淮璁板綍...
No.1
jsp欏甸潰涓殑鑴氭湰浠g爜 闇瑕佸紩鍏?br />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
1
<!--欏甸潰jquery鑴氭湰-->
2
3
function updateQuantity()
{
4
$.getJSON("${ctx}/do/material/updateQuantity?id="+$('#id').val()+"&quantity="+$('#quantity').val()+"×tamp="+new Date().getTime(),
5
function(data)
{
6
//閬嶅巻JSON涓殑姣忎釜entry
7
$.each(data,function(entryIndex,entry)
{
8
var html='<tr>';
9
//涔熷彲浠ュ啓鎴恊ntry.id entry.state
10
html+='<td>'+entry['id']+'</td>';
11
html+='<td>璧勬枡鐘舵?nbsp; '+entry['state']+'</td>';
12
html+='<td>'+entry['serialNumber']+'</td>';
13
html+='</tr>';
14
$('#title').html(html);
15
16
});
17
});
18
}
No.2
鍚庡彴controller浠g爜
1
/** *//**
2
* 灝嗕紶鍏ョ殑瀵硅薄杞寲涓篔SON鏁版嵁鏍煎紡
3
*/
4
protected JSONObject toJSONObject(Object obj) throws SecurityException, JSONException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
5
InvocationTargetException
{
6
JSONObject jobj = new JSONObject();
7
Field[] fields = obj.getClass().getDeclaredFields();
8
for (Field field : fields)
{
9
// 璇誨彇obj鍐呴儴鐨勫璞″睘鎬?
10
if (field.getName().equals("department"))
{
11
Object m = obj.getClass().getMethod("get" + StringUtils.capitalize("department")).invoke(obj);
12
jobj.put("id", m.getClass().getMethod("get" + StringUtils.capitalize("id")).invoke(m));
13
jobj.put("name", m.getClass().getMethod("get" + StringUtils.capitalize("name")).invoke(m));
14
continue;
15
}
16
// 榪囨護鎺塻et鎴愬憳鍙橀噺
17
if (field.getType().equals(Set.class))
{
18
continue;
19
}
20
// 鎴愬憳鍙橀噺鏄疍ate
21
if (field.getType().equals(Date.class))
{
22
Object invoke = obj.getClass().getMethod("get" + StringUtils.capitalize(field.getName())).invoke(obj);
23
String format = DateFormat.getDateInstance(DateFormat.DEFAULT).format(invoke);
24
// System.out.println(field.getName() + "===>" + format);
25
jobj.put(field.getName(), format);
26
continue;
27
}
28
// 鎴愬憳鍙橀噺鏄疊oolean
29
if (field.getType().equals(Boolean.class))
{
30
jobj.put(field.getName(), obj.getClass().getMethod("is" + StringUtils.capitalize(field.getName())).invoke(obj));
31
continue;
32
}
33
try
{
34
jobj.put(field.getName(), obj.getClass().getMethod("get" + StringUtils.capitalize(field.getName())).invoke(obj));
35
} catch (Exception e)
{
36
continue;
37
}
38
}
39
return jobj;
40
}
model杞瀷涓簀son鏁版嵁鏃訛紝鐢ㄤ簡鍙嶅皠瀵筸odel涓垚鍛樺彉閲忎負闆嗗悎(Set)銆丅oolean銆丏ate榪涜鐗規畩澶勭悊銆?br />
PS:json鏍煎紡
[{},
{ "name":"value", "name":"value",
"children":[{ "name":"value", "attributes":{ "url":"/do/postRequirement/postRequirementList" }},{ "name":"value", "attributes":{ "url":"/do/trainingPlan/trainingPlanList" } }]
},
{},{},{},{},{}]
json鏁翠綋鏍煎紡涓篬{},{},{}] ,鍐呴儴鏁版嵁涓烘鍩烘湰緇撴瀯鐨勫鍚堛倇}鍐呴儴鏈夐泦鍚堢粨鏋勶紝濡傦細children,涔熸槸浠]鏉ュ寘鍚傚唴閮ㄧ粨鏋勫悕縐版槸鑷畾鐨?涓漢鐞嗚В)銆?br />
璇︾粏鏍煎紡錛?a >http://www.json.org/json-zh.html

]]>
主站蜘蛛池模板:
韩城市|
湖州市|
视频|
石楼县|
河北区|
青海省|
栾川县|
青铜峡市|
扬州市|
新余市|
漳州市|
兰考县|
定西市|
北安市|
瓦房店市|
兴国县|
响水县|
迁安市|
赤水市|
五华县|
南木林县|
茶陵县|
青浦区|
香港
|
仙居县|
灵武市|
若尔盖县|
衡阳市|
游戏|
桂林市|
和林格尔县|
蒲城县|
襄垣县|
北碚区|
白银市|
淮北市|
四会市|
边坝县|
西宁市|
武清区|
历史|