我是靠谱客的博主 幸福短靴,这篇文章主要介绍ajax后台处理返回json值示例代码,现在分享给大家,希望可以做个参考。

复制代码 代码如下:

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后台处理返回json值示例代码内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(218)

评论列表共有 0 条评论

立即
投稿
返回
顶部