手机
当前位置:查字典教程网 >编程开发 >AJAX相关 >ajax后台处理返回json值示例代码
ajax后台处理返回json值示例代码
摘要:复制代码代码如下:publicActionForwardxsearch(ActionMappingmapping,ActionFormfor...

复制代码 代码如下:

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;

}

【ajax后台处理返回json值示例代码】相关文章:

ajax实现远程通信

Ajax修改购物车示例

往xml中更新节点的实例代码

Ajax叠加(Ajax返回数据用Ajax发出)示例代码

JavaScript如何控制Session实现原理及代码

asp.net jquery+ajax异步刷新实现示例

用实现ajax读博客rss示例代码

Ajax——异步检查用户名是否存在示例

ajax调用简单实例

ajax实例入门代码

精品推荐
分类导航