手机
当前位置:查字典教程网 >编程开发 >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异步处理POST表单中的数据示例代码

通过数据库和ajax方法写出地图的实例代码

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

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

用Ajax来控制书签和回退按钮的代码

ajax 技术和原理分析

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

Ajax局部刷新应用案例---简单登录

Ajax实现弹出式无刷新城市选择功能代码

精品推荐
分类导航