欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ajax后臺處理返回json值示例代碼

 更新時(shí)間:2013年09月05日 17:38:28   作者:  
很多的新手朋友們不知道ajax如何處理返回json值,在本文將為大家詳細(xì)介紹下
復(fù)制代碼 代碼如下:

public ActionForward xsearch(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String parentId = request.getParameter("parentId");
String supplier = request.getParameter("supplier");
List itemList = new ArrayList();
if(parentId.equals("")){
parentId="0";
}
Map map=new TawApTreeServlet().getTypeList(parentId, supplier);

for (Iterator rowIt = map.keySet().iterator(); rowIt.hasNext();) {
String id = (String) rowIt.next();
TawCommonsUIListItem uiitem = new TawCommonsUIListItem();
uiitem.setItemId(id);
uiitem.setText((String)map.get(id));
uiitem.setValue(id);
itemList.add(uiitem);
}

response.setContentType("text/xml;charset=UTF-8");

// 返回JSON對象
response.getWriter().print(JSONUtil.list2JSON(itemList));
return null;
}

相關(guān)文章

最新評論